Link to home
Start Free TrialLog in
Avatar of lkirke
lkirkeFlag for Australia

asked on

Format Worksheets via VBA Array

Hello Experts,

Have the following code, but it is not working as I anticipated. Probably missed something obvious. Any thoughts?

Regards

LK
Sub Format_Sheet()
    Dim ws As Worksheet
        
    For Each ws In sheets(Array "Sheet1", "Sheet2", "Sheet3"))
    ws.Select

    'Formats entire worksheet with Courier New font
    Cells.Select
    With Selection.Font
        .Name = "Courier New"
        .Size = 9
    ActiveWindow.Zoom = 90
    
    Next ws
           
End Sub

Open in new window

Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

   For Each ws In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
use this code
Sub Format_Sheet()
    Dim ws As Worksheet
        
    For Each ws In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
    ws.Select

    'Formats entire worksheet with Courier New font
    Cells.Select
    With Selection.Font
        .Name = "Courier New"
        .Size = 9
    End With
    ActiveWindow.Zoom = 90
    
    Next ws
           
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rob Brockett
Rob Brockett
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lkirke

ASKER

Thank you Experts for the prompt reponse. :)
hi Lk,

Thanks for the points but I don't think I deserve them all. After all, I only changed 3-4 lines of Ssaqibh's working code...

Rob