dsgsandman
New Member
- Joined
- Jan 29, 2009
- Messages
- 47
I've got a long list of worksheets that I need to copy into a new workbook. I only want to copy these specific tabs to a new workbook. For each row of data, the corresponding sheet name that needs to be moved, can be created by combining the 15th column, a space and then the 1st column. Basically the tab name would be Indirect(O3&" "&A3), all the way down like 500 rows. I've taken a crack at writing the code myself. but, I get object variable not set. and it points to the TabName row when you go to debug.
Any idea what's the problem. I'm fairly new to this.
Any help would be appreciated.
Sub ZZZZTysonMoveSpecificDivisonTabs()
Dim TabName As Worksheet, ss As Worksheet, TysonCopy As Workbook
LastRow = Range("A65536").End(xlUp).Row
For Row = 3 To LastRow Step 1
TabName = Cells(Row, 15).Value & " " & Cells(Row, 1).Value
If TysonCopy Is Nothing Then
Sheets(TabName).Copy
Set TysonCopy = ActiveWorkbook
Else: Sheets(TabName).Copy after:=ss
End If
Next Row
End Sub
Any idea what's the problem. I'm fairly new to this.
Any help would be appreciated.
Sub ZZZZTysonMoveSpecificDivisonTabs()
Dim TabName As Worksheet, ss As Worksheet, TysonCopy As Workbook
LastRow = Range("A65536").End(xlUp).Row
For Row = 3 To LastRow Step 1
TabName = Cells(Row, 15).Value & " " & Cells(Row, 1).Value
If TysonCopy Is Nothing Then
Sheets(TabName).Copy
Set TysonCopy = ActiveWorkbook
Else: Sheets(TabName).Copy after:=ss
End If
Next Row
End Sub