ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through sheets (https://www.excelbanter.com/excel-programming/272560-looping-through-sheets.html)

Eric[_7_]

Looping through sheets
 
I want to be able to loop through sheets that I have
created but I am unsure of how to do it. I am experienced
with For...Next loops, just not with sheets. What I am
trying to accomplish is below...

Dim cell as Range
'Dim sheet as Range - remarked out for now...
For each sheet...

For Each cell In Range("A2:A200").Cells
Select Case cell.Value

Case 151
cell.Value = "Fall Audit"
With cell.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Case 175
cell.Value = "Fall Audit"
With cell.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Case Else
Exit For
End Select
Next cell

Next sheet

Any ideas???

Derek[_2_]

Looping through sheets
 
Sub loopSheets()
Dim wkSht As Worksheet

For Each wkSht In Worksheets
' code
Next wkSht
End Sub
-----Original Message-----
I want to be able to loop through sheets that I have
created but I am unsure of how to do it. I am experienced
with For...Next loops, just not with sheets. What I am
trying to accomplish is below...

Dim cell as Range
'Dim sheet as Range - remarked out for now...
For each sheet...

For Each cell In Range("A2:A200").Cells
Select Case cell.Value

Case 151
cell.Value = "Fall Audit"
With cell.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Case 175
cell.Value = "Fall Audit"
With cell.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Case Else
Exit For
End Select
Next cell

Next sheet

Any ideas???
.



All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com