mcwillis81
New Member
- Joined
- Dec 3, 2015
- Messages
- 30
Hi All,
HELP, I'm confused....
The below code works at home on excel 2016 however in work where we use 2010 it fails on the wb.sheets(arr).copy line any suggestions? is it really a version difference or am i missing something?
Thanks in advance for any suggestions
HELP, I'm confused....
The below code works at home on excel 2016 however in work where we use 2010 it fails on the wb.sheets(arr).copy line any suggestions? is it really a version difference or am i missing something?
Thanks in advance for any suggestions
Code:
Sub copysheets()
Dim Tbl As ListObject
Dim arr() As String
Dim WB As Workbook, newWB As Workbook
Set WB = ThisWorkbook
Set Tbl = Sheet5.ListObjects(1)
ReDim arr(1 To Tbl.ListRows.Count)
For i = 1 To Tbl.ListRows.Count
arr(i) = Tbl.DataBodyRange(i, 1)
Next i
Set newWB = Workbooks.Add
ThisWorkbook.Sheets(arr).Copy newWB.Sheets(1)
End Sub