Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings:
I wrote the below macro which uses the For Each Next Loop. The purpose of the macro is to select a specific cell on each worksheet except the last worksheet in the workbook. I am surprised that in order for it to work, my macro has to select the first sheet in the selection before entering the For Each Next Loop and then use the ActiveSheet.Next.Select instruction in the For Each Next Loop to move on to the next sheet to be processed. LstRowData was computed elsewhere and is the last row of the worksheet which contains the input data. Sub CheckForEachNext() ' ' Hotkey: Ctrl+Shift+J ' Dim LstRowData As Long 'Without the below instruction and the ActiveSheet.Next.Select instruction, only the ' activesheet is processed. With the below instruction, but still without ActiveSheet.Next.Select, only the first worksheet is processed. ActiveWorkbook.Worksheets(1).Select Dim WS As Worksheet For Each WS In ActiveWorkbook.Worksheets If ActiveSheet.Name < "Sheet1" Then LstRowData = Range("O2") Cells(LstRowData + 9, "W").Select ' With the below ActiveSheet.Next.Select instruction but without the above ' ActiveWorkbook.Worksheets(1).Select instruction, only the ActiveSheet through ' the last sheet are processed. ActiveSheet.Next.Select Else Exit For End If Next WS MsgBox "I am done" End Sub -- All suggestions will be greatly appreciated. May you have a most blessed day! Sincerely, Michael Fitzpatrick |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data from SQL to Excel in a formated manner.. | Excel Programming | |||
comapre two list of data & arranging in a same manner | New Users to Excel | |||
How do I add up row sums in a systematic manner? | Excel Programming | |||
shell to behave in synchronous manner | Excel Programming | |||
macro needed for sorting txt in a ceratian manner | Excel Programming |