VBA with/end with multiple reoccurring steps enhancement

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
843
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello - looking to see if there is a better way to do what i am doing below. Cleaner and shorter maybe? each sheet I am doing the same thing for wasnt sure is the way i have is it the most efficient VBA route. Any help is appreciated.

VBA Code:
'clear all sheets below
With WsFT1
    .Range("A11:F" & rows.count).ClearContents
End With

With WsTR1
    .Range("A11:N" & rows.count).ClearContents
End With

With WsSEC1
    .Range("A11:G" & rows.count).ClearContents
End With

With WsTRF1
    .Range("A11:N" & rows.count).ClearContents
End With

With wsFOFL
    .Range("A11:G" & rows.count).ClearContents
End With
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
As far as efficiency, you have it. The only tweaks I could make is this. It's not going to make any time difference unless you have hundreds of these.
VBA Code:
Dim RowCnt As Long
  RowCnt = WsFT1.Rows.Count
  WsFT1.Range("A11:F" & RowCnt).ClearContents
  WsTR1.Range("A11:N" & RowCnt).ClearContents
  WsSEC1.Range("A11:G" & RowCnt).ClearContents
  WsTRF1.Range("A11:N" & RowCnt).ClearContents
  wsFOFL.Range("A11:G" & RowCnt).ClearContents
 
Upvote 0
Solution

Forum statistics

Threads
1,221,838
Messages
6,162,286
Members
451,759
Latest member
damav78

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