![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 7
|
Simple question, I think. I'm currently doing this by Sheets(Array("TOTAL", "K12", "HIED")).Select but would rather be able to just say something like Sheets(All).Select so that when the number of workbooks changes, my macro doesn't have to.
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,064
|
try this
simple code will add test in cell a1 all sheets ................... Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")).Select Sheets("Sheet2").Activate ActiveCell.FormulaR1C1 = "test" Range("A2").Select Sheets("Sheet3").Select ............. amend to suite
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 7
|
Yes, agreed this will add it to a1 in all cells, but that is not quite what I was asking by the question. Basically, rather than specifically having to select Sheet 1, Sheet 2, Sheet 3, Sheet 4, etc. I just want to select ALL sheets (so that when the number of sheets changes in the future, my macro automatically picks them up).
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Posts: 124
|
Dim arrSheets() As String, intCnt As Integer
ReDim arrSheets(Sheets.Count - 1) Do Until intCnt = Sheets.Count arrSheets(intCnt) = Sheets(intCnt + 1).Name intCnt = intCnt + 1 Loop ThisWorkbook.Sheets(arrSheets).Select |
|
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2002
Posts: 7
|
I took out the "ThisWorkbook." in the last line and it worked like a charm. Thanks!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|