View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Refer to a lone sheet

you've been given two alternatives, but activesheet still works even if the
workbook itself isn't teh active workbook.
you can't SELECT a cell in this activesheet if the book isn't active,but you
generally don't neeed cells to be selected in order to use them


so open a new excel instance, and add this code to book1
Sub test()
Workbooks("book1").ActiveSheet.Range("A1") = 1
End Sub

add a couple more books so that book2 or book3 is active. the code still
runs ok


"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