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

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
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: 8

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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
 
Upvote 0
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
 
Upvote 0
Solution
Thanks for everyone's input. It works wonderfully now.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,954
Members
448,535
Latest member
alrossman

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