Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Referring to the only sheet

Excel XP & Win XP
This is very simple but I can't quite hit it.
I have a variable workbook set to the variable "wbCMP". That workbook has
only one sheet and the sheet name is variable. That workbook is NOT the
active workbook. I want to refer to that single sheet in a With .../End
With construct, as in:
With wbCMP.Sheet1
'Copy/paste data
End With
I tried .Sheets(Sheet1)
..Sheets(Sheet(1))
..Sheet(1)
to no avail.
What is the proper syntax to refer to that lone sheet? Thanks for your
time. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Referring to the only sheet

Hi Otto,

Try:

'=============
Public Sub Tester()
Dim wbCMP As Workbook
Dim SH As Worksheet

Set wbCMP = Workbooks("MyBook.xls")

Set SH = wbCMP.Sheets(1)
MsgBox SH.Name

End Sub
'<<=============


---
Regards,
Norman


"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
This is very simple but I can't quite hit it.
I have a variable workbook set to the variable "wbCMP". That workbook has
only one sheet and the sheet name is variable. That workbook is NOT the
active workbook. I want to refer to that single sheet in a With .../End
With construct, as in:
With wbCMP.Sheet1
'Copy/paste data
End With
I tried .Sheets(Sheet1)
.Sheets(Sheet(1))
.Sheet(1)
to no avail.
What is the proper syntax to refer to that lone sheet? Thanks for your
time. Otto



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Referring to the only sheet

Hi Otto,

try

With wbCMP.Sheets(1)
msgbox .Name 'pop up the sheet name
End With


--
Hope that helps.

Vergel Adriano


"Otto Moehrbach" wrote:

Excel XP & Win XP
This is very simple but I can't quite hit it.
I have a variable workbook set to the variable "wbCMP". That workbook has
only one sheet and the sheet name is variable. That workbook is NOT the
active workbook. I want to refer to that single sheet in a With .../End
With construct, as in:
With wbCMP.Sheet1
'Copy/paste data
End With
I tried .Sheets(Sheet1)
..Sheets(Sheet(1))
..Sheet(1)
to no avail.
What is the proper syntax to refer to that lone sheet? Thanks for your
time. Otto



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Referring to the only sheet

Norman, Vergel
Such a simple thing! Thanks for taking the time to help me with this.
Otto
"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
This is very simple but I can't quite hit it.
I have a variable workbook set to the variable "wbCMP". That workbook has
only one sheet and the sheet name is variable. That workbook is NOT the
active workbook. I want to refer to that single sheet in a With .../End
With construct, as in:
With wbCMP.Sheet1
'Copy/paste data
End With
I tried .Sheets(Sheet1)
.Sheets(Sheet(1))
.Sheet(1)
to no avail.
What is the proper syntax to refer to that lone sheet? Thanks for your
time. Otto



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
referring to a sheet in another file Tami Excel Worksheet Functions 1 May 31st 08 01:56 PM
Formula referring to a different sheet luvthavodka Excel Discussion (Misc queries) 1 November 12th 06 10:05 PM
Referring to a sheet Virginia Excel Programming 2 April 10th 05 02:50 PM
Referring to a cell in another sheet Mike D. Excel Programming 2 April 5th 05 02:49 AM
referring to previous sheet Iolao Excel Discussion (Misc queries) 3 November 26th 04 08:40 PM


All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"