FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,366
- Office Version
- 365
- 2016
- Platform
- Windows
I have an array of worksheets that need to have the used ranges cleared. This works fine, but now can I use it when you use a variable and Set the names of the worksheets?
This does not work for me -- Dim ShtArr: ShtArr = Array("wsone", "wstwo", "wsthree", "wsfour")
This does not work for me -- Dim ShtArr: ShtArr = Array("wsone", "wstwo", "wsthree", "wsfour")
Code:
Sub ClearSheets()
Dim wsone As Worksheet: Set wsone = Sheets("Inventory")
Dim wstwo As Worksheet: Set wstwo = Sheets("Sales")
Dim wsthree As Worksheet: Set wsthree = Sheets("Work Hours")
Dim wsfour As Worksheet: Set wsfour = Sheets("Misc")
Dim ShtArr: ShtArr = Array("Inventory", "Sales", "Work Hours", "Misc")
Dim ShtArrCounter As Long
For ShtArrCounter = 0 To UBound(ShtArr): Sheets(ShtArr(ShtArrCounter)).UsedRange.Clear: Next
End Sub