Simple macro running very slow

mwollert

New Member
Joined
Jul 13, 2020
Messages
27
Office Version
  1. 365
Platform
  1. Windows
I added a macro to a worksheet that fills in 36 cells when a user double clicks a cell. It was working fine and then suddenly it is taking nearly 10 seconds to fill in 36 cells with numbers I tried turning off EnableEvents and ScreenUpdating but still takes about 10 seconds, Very strange.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Intersect(Target, Range("A3:BL42")) Then
        
      
            EditBudgetAccount Target.Row
       
    End If
    Cancel = True
End Sub

Sub EditBudgetAccount(Act As Integer)
   Application.ScreenUpdating = False
   Application.EnableEvents = False
   
    
    Dim Ws As Worksheet
    Set Ws = ActiveSheet
    With Ws
  
        .Cells(3, "BS") = .Cells(Act, "B")
        
        For Mon = 1 To 12
            .Cells(Mon + 4, 71) = .Cells(Act, (Mon - 1) * 5 + 5)
            .Cells(Mon + 4, 72) = .Cells(Act, (Mon - 1) * 5 + 6)
            .Cells(Mon + 4, 73) = .Cells(Act, (Mon - 1) * 5 + 7)
        Next Mon
  
    End With
   Application.ScreenUpdating = True
   Application.EnableEvents = True
   
End Sub

Any suggestions would be appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try also to turn off the calculation to see if it's better …​
 
Upvote 0
Follow up. I changed my data back to a range instead of a table and now it runs in less than a second. Not sure why a Table would slow the macro down so much.
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,940
Members
449,275
Latest member
jacob_mcbride

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