Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Name sheets in VB and Selecting them.



I am tyring to select a sheet in VB. I want to avoide using the sheet name
as the user may change this over time. I clicked onto the sheet in the VBA
Project Window and then went into the Name proptery in the Proptery window
and named it "VbImportSheet". When I use the followig line of code I get an
error:

Worksheets(VbImportSheet).Select

The error is a Run Time Error 9 Subscript out of range

What am I doing wrong?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Name sheets in VB and Selecting them.

I put quotes in: Sheets("VbImportSheet").Select
and this did not work either.

Why?

"ExcelMonkey" wrote:



I am tyring to select a sheet in VB. I want to avoide using the sheet name
as the user may change this over time. I clicked onto the sheet in the VBA
Project Window and then went into the Name proptery in the Proptery window
and named it "VbImportSheet". When I use the followig line of code I get an
error:

Worksheets(VbImportSheet).Select

The error is a Run Time Error 9 Subscript out of range

What am I doing wrong?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Name sheets in VB and Selecting them.

Hi ExcelMonkey,

Try:

VbImportSheet.Select

---
Regards,
Norman



"ExcelMonkey" wrote in message
...


I am tyring to select a sheet in VB. I want to avoide using the sheet
name
as the user may change this over time. I clicked onto the sheet in the
VBA
Project Window and then went into the Name proptery in the Proptery window
and named it "VbImportSheet". When I use the followig line of code I get
an
error:

Worksheets(VbImportSheet).Select

The error is a Run Time Error 9 Subscript out of range

What am I doing wrong?

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Name sheets in VB and Selecting them.

Hi Excel Monkey,

Try:

VbImportSheet.Select

---
Regards,
Norman



"ExcelMonkey" wrote in message
...
I put quotes in: Sheets("VbImportSheet").Select
and this did not work either.

Why?

"ExcelMonkey" wrote:



I am tyring to select a sheet in VB. I want to avoide using the sheet
name
as the user may change this over time. I clicked onto the sheet in the
VBA
Project Window and then went into the Name proptery in the Proptery
window
and named it "VbImportSheet". When I use the followig line of code I get
an
error:

Worksheets(VbImportSheet).Select

The error is a Run Time Error 9 Subscript out of range

What am I doing wrong?

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Name sheets in VB and Selecting them.

If you are using the codename of the sheet, you don't use the
Worksheets(). Excel has no knowledge of code name, only VBA does.
Therefore, you should use code like

VbImportSheet.Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ExcelMonkey" wrote in
message
...


I am tyring to select a sheet in VB. I want to avoide using
the sheet name
as the user may change this over time. I clicked onto the
sheet in the VBA
Project Window and then went into the Name proptery in the
Proptery window
and named it "VbImportSheet". When I use the followig line of
code I get an
error:

Worksheets(VbImportSheet).Select

The error is a Run Time Error 9 Subscript out of range

What am I doing wrong?

Thanks



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
Selecting all sheets Dana DeLouis[_3_] Excel Programming 0 May 11th 04 12:25 AM
Selecting all sheets Ron de Bruin Excel Programming 1 May 10th 04 07:56 PM
Selecting all sheets Don Guillett[_4_] Excel Programming 0 May 10th 04 06:38 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM
selecting sheets jacqui[_2_] Excel Programming 0 September 11th 03 02:46 PM


All times are GMT +1. The time now is 08:10 PM.

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

About Us

"It's about Microsoft Excel"