Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Declaring Worksheets

I would include the workbook object

With ActiveWorkbook
Set wsQty = .Worksheets(1)
Set wsSales = .Worksheets(2)
Set wsfinal = .Worksheets(3)
End With

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"RSteph" wrote in message
...
I have an excel workbook with 3 worksheets in it. I'm looking to do some
formatting to the first two pages, and then pull some information from
each
of them to the third page, to create a final report.

for ease of navigation between each page in the code, I'm made 3 variables
of type worksheet, one to hold each sheet. I've opened external sheets
before, from other workbooks, but never within the same workbook, so I
wanted
to double check that I'm doing this right.

Can I simply instantiate my variables like this?:
Set wsQty = Worksheets(1)
Set wsSales = Worksheets(2)
Set wsfinal = Worksheets(3)

Assuming that the first page in the quantities, 2nd is sales, and 3rd page
is where the final report will go.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Declaring Worksheets

I use something similar, however I use it as a sub of its own that i
call when the program launches.

Public Sub SetSheets(x As Byte)
'this runs each time the UI is shown to set the sheet names variables
Set shtCover = ThisWorkbook.Sheets("Budget Creator")
Set shtBudget = ThisWorkbook.Sheets("Budget")
Set shtDetail = ThisWorkbook.Sheets("Detail")
Set shtVar = ThisWorkbook.Sheets("Budget Variables")
Set shtBNotes = ThisWorkbook.Sheets("Build Notes")
Set shtBugList = ThisWorkbook.Sheets("Bug List")

End Sub

and I place the following in the GlobalVariable module

'Worksheet Variables
' for variable assignments look for the SetSheets sub in Module1
Public shtCover As New Worksheet
Public shtBudget As New Worksheet
Public shtDetail As Worksheet
Public shtVar As New Worksheet
Public shtBNotes As New Worksheet
Public shtBugList As New Worksheet

It works for me in most cases.

theSquirrel


Bob Phillips wrote:
I would include the workbook object

With ActiveWorkbook
Set wsQty = .Worksheets(1)
Set wsSales = .Worksheets(2)
Set wsfinal = .Worksheets(3)
End With

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"RSteph" wrote in message
...
I have an excel workbook with 3 worksheets in it. I'm looking to do some
formatting to the first two pages, and then pull some information from
each
of them to the third page, to create a final report.

for ease of navigation between each page in the code, I'm made 3 variables
of type worksheet, one to hold each sheet. I've opened external sheets
before, from other workbooks, but never within the same workbook, so I
wanted
to double check that I'm doing this right.

Can I simply instantiate my variables like this?:
Set wsQty = Worksheets(1)
Set wsSales = Worksheets(2)
Set wsfinal = Worksheets(3)

Assuming that the first page in the quantities, 2nd is sales, and 3rd page
is where the final report will go.


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
Declaring variables for use in multiple worksheets tompl Excel Discussion (Misc queries) 0 April 8th 10 04:40 PM
Declaring variables freekrill Excel Discussion (Misc queries) 0 July 18th 06 06:15 PM
Trouble with Declaring Worksheets Craig[_21_] Excel Programming 6 September 10th 05 09:26 AM
declaring a certain value thephoenix12[_4_] Excel Programming 2 June 28th 05 02:31 PM
Declaring a DLL Erich Neuwirth Excel Programming 1 May 10th 04 06:27 PM


All times are GMT +1. The time now is 07:25 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"