LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Subscript out of range

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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subscript out of range OKHM Excel Discussion (Misc queries) 0 August 6th 09 05:18 PM
what does 'Subscript Out of range' mean?? Gary Excel Worksheet Functions 2 March 22nd 07 01:33 AM
Subscript out of Range Jon[_22_] Excel Programming 4 April 6th 06 11:24 PM
Subscript out of range? Jason Hancock Excel Programming 3 May 26th 04 07:11 PM
Subscript Out of Range John Wilson Excel Programming 2 September 7th 03 04:07 AM


All times are GMT +1. The time now is 01:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"