Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
Too Many Variables | Excel Worksheet Functions | |||
Using variables in a name | Excel Discussion (Misc queries) | |||
Variables | Excel Programming | |||
DIm Variables | Excel Programming |