For next question
Hi,
Your code shouldn'y have applied the formatting to the sheet called
macro.xls and if it did then check the spelling is the same as in the code.
I'd change your code slightly to this
Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
If sht.Name < "Macro.xls" Then
With sht
.Range("A6:C6").BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
.Range("A7:C11").BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
.Range("A12:C16").BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
.Range("A17:C21").BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
End With
End If
Next sht
End Sub
Mike
"Faboboren" wrote:
Hi,
I have this code that I want to run in 15 sheets. I do not want to run where
I have my macros. It is not giving me error, but still applying borders in
Macro sheet. Please any idea to solve that?
Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
If sht.Name < "Macro.xls" Then
With sht.Range("A6:C6")
.BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
End With
With sht.Range("A7:C11")
.BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
End With
With sht.Range("A12:C16")
.BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
End With
With sht.Range("A17:C21")
.BorderAround LineStyle:=xlSolid, Weight:=xlMedium,
ColorIndex:=xlAutomatic
End With
End If
Next sht
End Sub
|