Hi,
I need to select multiple sheets (based on the contents of a range of cells) and copy those sheets to a new workbook. Each cell in the range contains a sheet name that I need to export.
I have the code written almost to where I need it to be, but I can't get the macro to select all of the sheets, just cycles through them and select the last one (probably b/c I'm using a For...Next loop, I know). Any ideas would be really appreciated
Thanks!
Pete
I need to select multiple sheets (based on the contents of a range of cells) and copy those sheets to a new workbook. Each cell in the range contains a sheet name that I need to export.
I have the code written almost to where I need it to be, but I can't get the macro to select all of the sheets, just cycles through them and select the last one (probably b/c I'm using a For...Next loop, I know). Any ideas would be really appreciated
Code:
Sub arrayTest()
Dim a As Variant
Dim sheetname As String
Sheets("Export").Select
For i = 5 To Range("D5").Value
sheet_name = Sheets("Export").Range("B" & i).Value
Application.SendKeys "+", True
Sheets(sheet_name).Select
Worksheets.Copy
Next i
End Sub
Thanks!
Pete