View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] crferguson@gmail.com is offline
external usenet poster
 
Posts: 91
Default Exclude Sheets from Macro

Sheets(1).Select

Dim a As Integer
For a = 1 To (ActiveWorkbook.Sheets.Count - 3)
With ActiveSheet
.Columns(1).ColumnWidth = 51.57
.Columns(2).ColumnWidth = 8
.Range("C4:N4").HorizontalAlignment = xlRight
.Range("C4:N4").VerticalAlignment = xlTop
End With
ActiveSheet.Next.Select
Next a


Lambtwo wrote:
I want to exclude the last 3 worksheets from the following macro. Can you
please show how the code should be adjusted (and cleaned up). Many thanks.

Sub Sheetsless3()
Dim wSht As Worksheet
Dim myRng As Range
Dim allwShts As Sheets
Set allwShts = Worksheets
For Each wSht In allwShts
wSht.Columns(1).ColumnWidth = 51.57
wSht.Columns(2).ColumnWidth = 8
Set myRng = wSht.Range("C4:N4")
With myRng
.HorizontalAlignment = xlRight
.VerticalAlignment = xlTop
End With
Next wSht
End Sub