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: 1
Default Recall a variable referring to a worksheet name?

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
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
Referring to a variable cell on another sheet PaladinWhite Excel Worksheet Functions 5 March 24th 08 02:14 AM
Referring to a variable file name Brettjg Excel Discussion (Misc queries) 4 March 3rd 07 11:18 AM
referring to other worksheet Geetu M Excel Worksheet Functions 2 March 29th 05 09:37 PM
Referring to a worksheet using variable WSF Excel Programming 5 January 20th 04 03:16 PM
Referring to a local or global variable or constant dynamically? PC[_2_] Excel Programming 1 September 15th 03 02:31 PM


All times are GMT +1. The time now is 12:44 AM.

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"