View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default setting object variable

I guess the first question is why you want an object variable set
to Worksheets since you already have the built-in Worksheets
objects. That said, you can write code like

Dim Codes As Sheets
Set Codes = ThisWorkbook.Worksheets
Debug.Print Codes("Sheet1").Name


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



wrote in message
oups.com...
i am looking for some advice on object variables. I have a
module with
two sub routines in it. i have the following object variables
at
module level

dim codes as worksheets

i want to use this variable in both subs, and the
value(worksheet) will
be the same, so do i have to set the variable in both subs,
set codes = worksheets("sheet1)
this is what i am doing at the moment but i am not sure if
this is
correct or good programming.

regards
chris