Why does my run all stop dead in its track on a certain VBA

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I've completed a massive VBA with 26 Macros. They work great as I go through them one by one, but when I use the run all macro, it will stop at one specific Macro (Left_Align). When I place an apostrophe in front of it to block it on the run all, the VBA works fine. It is like something is telling the VBA to stop running. I need to keep the sequence in order, for some macros have to run before others. It is just the one worksheet "72 Hr" I need this to work on. Thank you,

VBA Code:
Sub Left_Align()
    Dim wks As Worksheet
    For Each wks In Worksheets
        ActiveSheet.Cells.Font.Name = "Times New Roman"
        ActiveSheet.Cells.Font.Size = 12
        ActiveSheet.Cells.HorizontalAlignment = xlLeft
        ActiveSheet.Cells.BorderAround xlNone
        ActiveSheet.Cells.VerticalAlignment = xlCenter
        ActiveSheet.Cells.EntireColumn.AutoFit
   End
   Next
      End Sub
 

Attachments

  • Run All.JPG
    Run All.JPG
    48.9 KB · Views: 6

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

NdNoviceHlp

Well-known Member
Joined
Nov 9, 2002
Messages
2,751
You also shouldn't be using active sheet as U haven't selected anything. Ergo...
Code:
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
wks.Cells.Font.Name = "Times New Roman"
wks.Cells.Font.Size = 12
wks.Cells.HorizontalAlignment = xlLeft
wks.Cells.BorderAround xlNone
wks.Cells.VerticalAlignment = xlCenter
wks.Cells.EntireColumn.AutoFit
Next
HTH. Dave
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,253
Office Version
  1. 365
Platform
  1. Windows
If you just want it to work on the 72 Hr sheet try
VBA Code:
Sub Left_Align()
   With Sheets("72 Hr").Cells
      .Font.Name = "Times New Roman"
      .Font.Size = 12
      .HorizontalAlignment = xlLeft
      .BorderAround xlNone
      .VerticalAlignment = xlCenter
      .EntireColumn.AutoFit
   End With
End Sub
 
Solution

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Thanks for everyone's input. It works wonderfully now.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,253
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,006
Messages
5,622,138
Members
415,880
Latest member
Bruce0203

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
Top