Do Until VBA Optimization

ItalianPlatinum

Active Member
Joined
Mar 23, 2017
Messages
434
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Hello - I am fairly basic on all my VBA, I have yet to find the best way on certain approaches. One approach is below, is there a better, faster, or more efficient way? i want to run my VBA "sec2" for each view on another sheet called views, then loop until it is finished.

VBA Code:
Sub TRAN()
Dim i%
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual

ActiveSheet.AutoFilterMode = False

Sheets("TRANS").Activate
Call Clear
i = 1
With Sheets("Views")
    Do Until .Range("VIEW").Offset(i, 0) = ""
    
    Sheets("TRANS").Range("SP") = .Range("VIEW").Offset(i, 0)
    Call Sec2
    
    i = i + 1
    Loop

End With

If Not ActiveSheet.AutoFilterMode Then ActiveSheet.Range("10:10").AutoFilter

Application.Calculation = xlCalculationAutomatic

With ActiveWindow
    .SplitColumn = 9
    .SplitRow = 10
    .FreezePanes = True
End With

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

End Sub
way to capture the below?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

vw412

Active Member
Joined
Dec 16, 2011
Messages
343
Office Version
  1. 2019
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
I can think of other ways to do it, but this is probably as efficient as any other. You could change your
VBA Code:
With Sheets("Views")
to
VBA Code:
With Sheets("Views").Range("View")
and then adjust the lines accordingly. That will remove a bit of redundant code - not much admittedly but looking for such is a good habit to get into.
 

Forum statistics

Threads
1,137,154
Messages
5,679,912
Members
419,862
Latest member
Bluewings666

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