Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
And you don't even need to select them:
Dim vArr As Variant vArr = Array("Sheet2", "Sheet3", "Sheet4") Sheets(vArr).Copy "anhjan <" wrote: Hello world! Ok, I have an array with values that equal some names of worksheets in my workbook. I want to use this array to select these worksheets and paste them into a new workbook. So my VBA works for the array values, but I don’t know the syntax to select the sheets based on the array value and then paste it. I used a record marco to see how it’s done, if I manually hold the <Ctrl down and select the particular sheets. Here’s what I got: Sub array_tester() Dim arrayList(0 To 12) As String Dim pointer As Integer pointer = 0 For CounterComp = 6 To 15 IncludeSheet = Worksheets("Labels").Cells(CounterComp, 31) DataSheet = Worksheets("Labels").Cells(CounterComp, 7) If IncludeSheet = True Then arrayList(pointer) = DataSheet pointer = pointer + 1 Else pointer = pointer + 1 End If Next CounterComp Sheets(Array(arraylist)).Select ‘Here’s where it doesn’t work for me… Selection.COPY Any help would be appreciated…Thanks! --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting Multiple Sheets in VBA | Excel Worksheet Functions | |||
selecting multiple sheets | Excel Worksheet Functions | |||
selecting multiple sheets | Excel Programming | |||
selecting multiple sheets | Excel Programming | |||
Changing the value in multiple sheets without selecting those sheets | Excel Programming |