I'm using Excel 2010 in Windows 8. I have a spreadsheet with a table that contains hyperlinks. I need to create multiple versions of the data. I was unable to find any info that showed Excel would allow me to create a pivot table and carry the hyperlinks over to the pivot, so I'm taking a different approach. I'm creating macro (I'm not a scriptwriter so I typically use the mouse to record and then modify the code as needed). The macro (1) copies the tab and creates a new tab, (2) renames the tab, (3) recolors the tab, (4) renames the table, (5) filters the data, and then (6) prints. Everything works fine while I'm creating the macro. I then save the workbook, delete the newly created sheets, and try to run the macro again, but I get this MVB error: Run-timer error '9': Subscript out of range. The debugger stops on this line: ActiveSheet.ListObjects("Solicita").Name = "Solicitations". Here's my code:
HTML:
Sub NewTabsandPrint()
'
' NewTabsandPrint Macro
'
'
Sheets("ALL").Select
Sheets("ALL").Copy Before:=Sheets(1)
Sheets("ALL (2)").Select
Sheets("ALL (2)").Name = "Solicitations"
Sheets("Solicitations").Select
With ActiveWorkbook.Sheets("Solicitations").Tab
.Color = 15773696
.TintAndShade = 0
End With
Range("A2").Select
ActiveSheet.ListObjects("Solicita").Name = "Solicitations"
ActiveSheet.ListObjects("Solicitations").Range.AutoFilter Field:=4, _
Criteria1:="=Combined Synopsis/ Solicitation", Operator:=xlOr, Criteria2 _
:="=Solicitation"
Sheets("ALL").Select
Sheets("ALL").Copy Before:=Sheets(2)
Sheets("ALL (2)").Select
Sheets("ALL (2)").Name = "Presolicitations"
Sheets("Presolicitations").Select
With ActiveWorkbook.Sheets("Presolicitations").Tab
.Color = 15773696
.TintAndShade = 0
End With
Range("A2").Select
ActiveSheet.ListObjects("Presolic").Name = "Presolicitations"
ActiveSheet.ListObjects("Presolicitations").Range.AutoFilter Field:=4, _
Criteria1:="Pre Solicitation"
Sheets("ALL").Select
Sheets("ALL").Copy Before:=Sheets(3)
Sheets("ALL (2)").Select
Sheets("ALL (2)").Name = "Sources Sought"
Sheets("Sources Sought").Select
With ActiveWorkbook.Sheets("Sources Sought").Tab
.Color = 15773696
.TintAndShade = 0
End With
Range("A2").Select
ActiveSheet.ListObjects("SourcesS").Name = "SourcesSought"
ActiveSheet.ListObjects("SourcesSought").Range.AutoFilter Field:=4, _
Criteria1:="Sources Sought"
Sheets("Solicitations").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Sheets("Presolicitations").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Sheets("Sources Sought").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub