Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to resolve define worksheets array

Status
Not open for further replies.

kelvinhang

Programmer
Aug 28, 2024
1
Original set wsSheet = wbBook.Worksheets("01"), but would like to change it as worksheets array from "01" to "02". How can I resolve?


Screenshot 2024-08-28 150533.png
 
There are some issues to solve.

First, declare worksheets, use As Sheets instead:
Code:
Dim wsSheet As Sheets

Second, work with the array of worksheet. It is possible only to apply logic from single sheet and apply to the rest, and it seems that activate/select is required:
Code:
wsSheets.Select
wsSheets.Item(1).Activate
wsSheets.Item(1).Cells(1, 1).Select
ActiveCell.Formula = "1"

If the target structure of of formulas/formats is has to be the same across sheets and you already have a template worksheet, you can use FillAcrossSheets

If the final result depends on contents of each sheet (colour testing), process each sheet separately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top