#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Variables

Most likely, you have "Option Explicit" at the top of the code
module; this directive makes variable declaration mandatory for
all procedures in the module. You should ALWAYS declare your
variables. Not doing so makes bugs much more likely. If, however,
you don't want to have to declare variables, remove "Option
Explicit" from the top of the module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Hargrove" wrote in message
...
I have the following macro. For some reason it stops at the

first "For x = 1 to 11". I have an identical macro that I
copy/pasted and changed the file names only that works just fine.
I can't figure out why it works with one file, but not the other.
With this one, I get a message that states I have not declared my
variables but I didn't think that was necessary since the other
copy of the macro works fine.

Any suggestions? How do you declare the variables?

Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(24, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
For x = 1 To 11
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement 2004_0

6.xls").Activate
ActiveCell.Offset(-1, 2).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
Next x
ActiveCell.Offset(63, -23).Range("A1").Select
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(-32, -13).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(24, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
For x = 1 To 11
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
ActiveCell.Offset(-1, 2).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
Next x
For y = 1 To 6
ActiveCell.Offset(63, -23).Range("A1").Select
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(-11, -13).Range("A1").Select
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(24, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
For x = 1 To 11
Windows("AgencyTertiaryBatchTrack 2004_06.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Agency Tertiary Gross Plotting by Placement

2004_06.xls").Activate
ActiveCell.Offset(-1, 2).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
Next x
Next y
Range("A1").Select
End Sub



Reply
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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Too Many Variables Heliocracy Excel Worksheet Functions 6 April 6th 07 07:02 PM
Using variables in a name Vispy Excel Discussion (Misc queries) 4 February 22nd 06 01:17 AM
Variables No Name Excel Programming 2 July 9th 04 05:37 AM
DIm Variables Todd Huttenstine Excel Programming 4 April 26th 04 04:37 PM


All times are GMT +1. The time now is 10:25 AM.

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

About Us

"It's about Microsoft Excel"