Horizontal / Vertical Alignment not Working

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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