Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am writing a macro with the intent that it can be used on any
workbook. The user selects the first cell in a column that needs to be modified in this particular way, then executes the macro. Since I don't know what the contents will be on the particular worksheet that this macro will be run, I plan on creating a new worksheet, modifiying the data here, then copying the modified data back to the original location on the original worksheet (and then deleting my temporary worksheet so that they never see it). Since I don't know what the name of the user's worksheet will be, I assigned it to a variable. But when I try to go back to that worksheet, referencing the variable, I get an error (Run-time error '9': Subscript out of range). Below is the pertinent code regarding the variable name. Dim DataSheet As Worksheet Set DataSheet = ActiveSheet '(I've also tried several other variations) .. .. .. Selection.Cut Sheets.Add.Name = "Temp" ActiveSheet.Paste Sheets("DataSheet").Select '(error occurs here) Any help would be greatly appreciated. Mike |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Referring to a variable cell on another sheet | Excel Worksheet Functions | |||
Referring to a variable file name | Excel Discussion (Misc queries) | |||
referring to other worksheet | Excel Worksheet Functions | |||
Referring to a worksheet using variable | Excel Programming | |||
Referring to a local or global variable or constant dynamically? | Excel Programming |