For Each Function, to loop through specifically named worksheets

Solaire

Im trying to figure out the right way to code a macro that goes through 12 worksheets with specific names (Jan,Feb,...,Dec). I thought maybe for each function will be a good choice so i tried the following:

dim crntSht as worksheet
set crntsht=("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
for each crntsht in worksheets
.
.
.
end for

this obviously did not work since I defined crntsht in the wrong manner.

Can anyone suggest the best way to loop through all 12 sheets once each, and skip all other sheets in the same workbook?

Thanks

ARich

Ah, Tim beat me... my answer is slightly different however...

Sub LoopThroughSheets()

    Dim Months As Variant
    Dim Month As Variant

    Months = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", _
         "Aug", "Sep", "Oct", "Nov", "Dec")

    For Each Month In Months
        'Code goes here.
    Next Month

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Loop through all my worksheets VBA with For Each

From Dev

loop through all worksheets and add sums/formulas at bottom of each

From Dev

For Each/Next Loop does not walk through all worksheets

From Dev

Flatten a loop through worksheets

From Dev

Add named worksheets using For Loop

From Dev

Loop with the each function through the html

From Dev

Loop through worksheets with a specific name

From Dev

Excel: Loop through different worksheets

From Dev

How to loop through named cells and list value for each

From Dev

How to loop through named cells and list value for each

From Dev

How to loop through a function for each item in list?

From Dev

.each() function does not loop through my object

From Dev

Loop through Worksheets with similar name structure in VBA

From Dev

Loop through the workbook but exclude some worksheets?

From Dev

How to make this code not loop through all the worksheets?

From Dev

Excel VBA to loop through Worksheets on a series of Workbooks

From Dev

Loop through Worksheets with similar name structure in VBA

From Dev

jquery each as 'named function'

From Dev

Loop through named range list

From Dev

Loop through function in python generating separate list for each set of data

From Dev

How do I loop through array and call function for each?

From Dev

Loop through each cell

From Dev

Excel VBA loop through all workbooks and all worksheets

From Dev

How to Loop through several worksheets in a Workbook Using a VBA UserForm

From Dev

Loop through directory, open workbook, print selected worksheets

From Dev

Macro to Run and Loop through all worksheets but the first one

From Dev

how to loop through each row of datatable in order to execute a function one by one for each row

From Dev

For Loop through Named Range cells names

From Dev

How to loop through a list of files that are sequentially named?

Related Related

  1. 1

    Loop through all my worksheets VBA with For Each

  2. 2

    loop through all worksheets and add sums/formulas at bottom of each

  3. 3

    For Each/Next Loop does not walk through all worksheets

  4. 4

    Flatten a loop through worksheets

  5. 5

    Add named worksheets using For Loop

  6. 6

    Loop with the each function through the html

  7. 7

    Loop through worksheets with a specific name

  8. 8

    Excel: Loop through different worksheets

  9. 9

    How to loop through named cells and list value for each

  10. 10

    How to loop through named cells and list value for each

  11. 11

    How to loop through a function for each item in list?

  12. 12

    .each() function does not loop through my object

  13. 13

    Loop through Worksheets with similar name structure in VBA

  14. 14

    Loop through the workbook but exclude some worksheets?

  15. 15

    How to make this code not loop through all the worksheets?

  16. 16

    Excel VBA to loop through Worksheets on a series of Workbooks

  17. 17

    Loop through Worksheets with similar name structure in VBA

  18. 18

    jquery each as 'named function'

  19. 19

    Loop through named range list

  20. 20

    Loop through function in python generating separate list for each set of data

  21. 21

    How do I loop through array and call function for each?

  22. 22

    Loop through each cell

  23. 23

    Excel VBA loop through all workbooks and all worksheets

  24. 24

    How to Loop through several worksheets in a Workbook Using a VBA UserForm

  25. 25

    Loop through directory, open workbook, print selected worksheets

  26. 26

    Macro to Run and Loop through all worksheets but the first one

  27. 27

    how to loop through each row of datatable in order to execute a function one by one for each row

  28. 28

    For Loop through Named Range cells names

  29. 29

    How to loop through a list of files that are sequentially named?

HotTag

Archive