Using VBA, how can I select multiple rows, on multiple worksheets for
printing?
I have a spreadsheet that contains multiple worksheets. I need to select
all rows, in certain worksheets, so that I can print all rows, across all
selected worksheets, to a single document.
The following code is used to select all pertinent worksheets and rows
that are to be printed. This code works until I attempt to select rows
from a second worksheet.
Dim no_selected_worksheets As Boolean
no_selected_worksheets = True
Dim list_choose As Long
For list_choose = 0 To FormsToPrint.ListCount - 1
If FormsToPrint.Selected(list_choose) Then
With Worksheets(list_choose + 2)
If no_selected_worksheets Then
.Select 'This works.
.Rows.Select 'So does this.
no_selected_worksheets = False
Else
.Select (False) 'This works too..
.Rows.Select ' but here, VBA reports the error:
' "Select Method of Range class failed"
End If
End With
End If
Next
How can I fix this bug?
No comments:
Post a Comment