A
Abdul
I have the following before save macro saved, but when I try to run the macro
I get the following error:
Run-time error '9':
Subscript out of range
and my macro looks like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("B1:B20").Select
Selection.Copy
Workbooks.Open Filename:= _
"C:\Documents and Settings\User\Desktop\Book1"
Windows("Book1").Activate
Sheets("Sheet1").Select
Application.Goto Reference:="R1C256"
Selection.End(xlToLeft).Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveSheet.Paste
End Sub
when I click on Debug
the line: Windows("Book1").Activate
becomes highlighted with flash yellow with an arrow on the left is visible.
when I try to ignore that step like this:
' Windows("Book1").Activate
the debugger highlights the next line..
if you know what's wrong with it or what should I do to correct it, please
assist.
this macro is supposed to copy the contents highlighted in the second line
and opens the file "book1" from the desktop and paste it at the next unused
cell starting from the end of the sheet [Range("VI1")]
if you know a better way to avoid those steps and use better ones please
provide me with assistance.
I get the following error:
Run-time error '9':
Subscript out of range
and my macro looks like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("B1:B20").Select
Selection.Copy
Workbooks.Open Filename:= _
"C:\Documents and Settings\User\Desktop\Book1"
Windows("Book1").Activate
Sheets("Sheet1").Select
Application.Goto Reference:="R1C256"
Selection.End(xlToLeft).Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveSheet.Paste
End Sub
when I click on Debug
the line: Windows("Book1").Activate
becomes highlighted with flash yellow with an arrow on the left is visible.
when I try to ignore that step like this:
' Windows("Book1").Activate
the debugger highlights the next line..
if you know what's wrong with it or what should I do to correct it, please
assist.
this macro is supposed to copy the contents highlighted in the second line
and opens the file "book1" from the desktop and paste it at the next unused
cell starting from the end of the sheet [Range("VI1")]
if you know a better way to avoid those steps and use better ones please
provide me with assistance.