Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet object assignment
I'm trying to assign a worksheet object to a variable at the time of its
creation through a copy function, but the process always fails with an "Object Variable Not Set" error. i.e.: Dim ns As Worksheet Set ns = Sheets(GrpShellTemp).Copy(Befo=Sheets(GrpShellT emp)) .... while in another module, "GrpShellTemp" is defined as a constant: Public Const GrpShellTemp As String = "GroupShell" When the code runs, the sheet in question IS copied and is placed before the one being copied, however the assignment fails and the error results. I know I can get around this by simply allowing the copy function to run without the assignment as follows: Sheets(GrpShellTemp).Copy Befo=Sheets(GrpShellTemp) .... and then assign the variable: Set ns = ActiveSheet .... but I shouldn't have to do this, should I? Why won't the assignment work at the time the sheet is copied? Thx HWH |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error | Excel Discussion (Misc queries) | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Charts and Charting in Excel | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Excel Discussion (Misc queries) | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Excel Worksheet Functions | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | New Users to Excel |