Refer to a lone sheet
With wb.worksheets(1)
From the help file:
---------------------
Referring to Sheets by Index Number
See AlsoSpecificsAn index number is a sequential number assigned to a sheet,
based on the position of its sheet tab (counting from the left) among sheets
of the same type. The following procedure uses the Worksheets property to
activate worksheet one in the active workbook.
Sub FirstOne()
Worksheets(1).Activate
End Sub
If you want to work with all types of sheets (worksheets, charts, modules,
and dialog sheets), use the Sheets property. The following procedure
activates sheet four in the workbook.
Sub FourthOne()
Sheets(4).Activate
End Sub
Note The index order can change if you move, add, or delete sheets.
"Otto Moehrbach" wrote:
Excel XP & Win XP
When a wb has only one sheet, the code name of that one sheet may not be
"Sheet1" if other sheets have been deleted.
If that wb is the active wb I can refer to that one sheet as "ActiveSheet".
My question comes when that workbook is not the active wb and I want to
paste into that one sheet. How do I refer to that one sheet to paste into
it, as in:
With wb.Sheets(???)
.range("A1").paste
End with
Thanks for your time. Otto
|