sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
I had the formula below that I want to modify from a different workbook. I would like to tweak it to accommodate two worksheets for another workbook now. For example, the new workbook sheet names could be "Drops1" and "Drops2" and maybe I would like to specify a different range of "A2:A8" for "Drops2". I tried just copying the first part over and putting it below after where it says "Next c" using the new worksheet names and ranges, but got an error message that said "Run-time error '9': Subscript out of range". Thanks in advance for any assistance, SS
VBA Code:
Sub Clear_And_Resize_Tables_v2()
Dim c As Range
For Each c In Range("A2:A14")
With Sheets("Drops").ListObjects(c.Value)
If WorksheetFunction.CountA(.Range) > .Range.Columns.Count Then .DataBodyRange.ClearContents
.Resize (.Range.Resize(c.Offset(, 1).Value))
End With
Next c
End Sub