Dynamic PivotTable source - limit sources
"NikkiS" wrote in message
...
I am still learning VBA.
I am building a workbook for users who are not very proficient with Excel.
The workbook has the potential to have many sheets. I have set up a
pivottable to be used with all sheets with "Archv" in the name. I have
been
able to alter the following code so that only THOSE sheets appear as an
option when a button is pressed, however they each appear 3 times. So
far, I
have not been able to narrow it down to just one. Can anyone help?
For Each ws In Sheets
If InStr(ws.Name, "Archv") 1 Then
With ws
myShts = ActiveWorkbook.Sheets.Count
For i = 8 To myShts 'the "Archv" sheets start with #8
myList = myList & i & " - " & ActiveWorkbook.Sheets(i).Name
& " " & vbCr
Next i
End With
End If
Next
Try just using...
myShts = ActiveWorkbook.Sheets.Count
For i = 8 To myShts 'the "Archv" sheets start with #8
myList = myList & i & " - " & ActiveWorkbook.Sheets(i).Name & " " & vbCr
Next
i.e. delete the outer loop - top and bottom 3 lines
--
Roger
|