Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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
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
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error [email protected] Excel Discussion (Misc queries) 4 September 25th 06 01:35 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Charts and Charting in Excel 3 August 24th 06 07:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Excel Discussion (Misc queries) 2 August 24th 06 05:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Excel Worksheet Functions 2 August 24th 06 05:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet jeftiong New Users to Excel 0 August 23rd 06 01:50 PM


All times are GMT +1. The time now is 02:19 PM.

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"