Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Set Sheets as variable

I am trying to set two sheets as variables and it is not working how I
thought it should.

I have declared them like this

Dim Sht As Worksheet
Dim Env As Worksheets
And tried to set them like this.
Set Sht = Sheet1
Set Env = Sheet2
It errors out on the Set Env line. I am not sure how to make this
right. I would prefer sot to have to use Sheet2 for evey place in my
code that I have Env.

Thanks,
Jay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Set Sheets as variable

On Dec 3, 10:57*am, jlclyde wrote:
I am trying to set two sheets as variables and it is not working how I
thought it should.

I have declared them like this

* * Dim Sht As Worksheet
* * Dim Env As Worksheets
And tried to set them like this.
* * Set Sht = Sheet1
* * Set Env = Sheet2
It errors out on the Set Env line. *I am not sure how to make this
right. *I would prefer sot to have to use Sheet2 for evey place in my
code that I have Env.

Thanks,
Jay


My bad. I have one as sheet and the other as sheets.
Sorry,
Jay
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Set Sheets as variable

Instead of using variables that represent those sheets, you could just change
the codename to what you want.

Open your workbook
Go into the VBE
Select your project
select the worksheet object
Hit F4 to see the project explorer
Change the (Name) property (with the ()'s) to what you want.

Then drop the dim statements completely.

jlclyde wrote:

On Dec 3, 10:57 am, jlclyde wrote:
I am trying to set two sheets as variables and it is not working how I
thought it should.

I have declared them like this

Dim Sht As Worksheet
Dim Env As Worksheets
And tried to set them like this.
Set Sht = Sheet1
Set Env = Sheet2
It errors out on the Set Env line. I am not sure how to make this
right. I would prefer sot to have to use Sheet2 for evey place in my
code that I have Env.

Thanks,
Jay


My bad. I have one as sheet and the other as sheets.
Sorry,
Jay


--

Dave Peterson
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
SUM command using variable sheets IanC Excel Worksheet Functions 3 May 18th 07 11:56 PM
add new sheets in a workbook with new sheets being a variable [email protected] Excel Discussion (Misc queries) 1 April 11th 06 08:38 PM
How to have a variable cell reference across sheets? Shane Gibson Excel Discussion (Misc queries) 3 March 8th 06 10:10 PM
Need Help: 'sheets' function with a variable in a formula livin Excel Worksheet Functions 2 September 7th 05 10:27 PM
Use of variable to identify range of sheets in a workbook rhs414 Excel Discussion (Misc queries) 1 June 20th 05 01:42 PM


All times are GMT +1. The time now is 03:05 AM.

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"