Horizontal / Vertical Alignment not Working

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
951
Office Version
  1. 2016
Platform
  1. Windows
Code:
For Each sht In ActiveWorkbook.Worksheets
    If (sht.Name = "Recovery") And (sht.Name = "Revisions") Then
    sht.Activate
        With Range("A7:AV3000")
            .Clear
            .NumberFormat = "General"
            .Interior.Pattern = xlNone
            Range("B6") = "Document Number"
            Range("B6").Interior.ColorIndex = 6
            Range("C6") = "Start"
            Range("C6").Interior.ColorIndex = 4
            Range("D6") = "Finish"
            Range("D6").Interior.Color = RGB(255, 157, 91)
        End With
        With Columns("A:D")
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            Columns("B:D").ColumnWidth = 19.01
            .Font.Name = "Calibri"
            .Font.Size = 12
        End With
    
    End If
Next sht

Hello All,
My code above, the section about Columns"A:D" is not working, and I don't know why?
What am I doing wrong?
Thanks for the help
excel 2013
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
A sheet name cannot be at once equal to Recovery and equal to Revisions

Code:
If (sht.Name = "Recovery") [COLOR=#ff0000]And[/COLOR] (sht.Name = "Revisions") Then

I think you should use a OR instead of AND

M.
 
Upvote 0
A sheet name cannot be at once equal to Recovery and equal to Revisions

Code:
If (sht.Name = "Recovery") [COLOR=#ff0000]And[/COLOR] (sht.Name = "Revisions") Then

I think you should use a OR instead of AND

Ahh...Thanks
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,398
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top