Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Change Sheet references in code?

I have some old code that refers to sheet names and I'd like to change these
to the sheet code names.
However, apparently code names are objects of a different type than sheet
Names.
Here's an example of what I'm trying to do:
Change
ThisWorkbook.Sheets("Report").Activate
To
ThisWorkbook.Sheet2.Activate 'Error: Method or Data Member not
found.
This seems elementary but I can't seem to get the syntax correct.
How can I refence a code name of a particula workbook?
Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Change Sheet references in code?

Try

ThisWorkbook.Sheets(2).Activate

you can also eliminate the ThisWorkbook (it is implied)

Sheets(2).Activate
--
If this helps, please remember to click yes.


"Bassman62" wrote:

I have some old code that refers to sheet names and I'd like to change these
to the sheet code names.
However, apparently code names are objects of a different type than sheet
Names.
Here's an example of what I'm trying to do:
Change
ThisWorkbook.Sheets("Report").Activate
To
ThisWorkbook.Sheet2.Activate 'Error: Method or Data Member not
found.
This seems elementary but I can't seem to get the syntax correct.
How can I refence a code name of a particula workbook?
Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Change Sheet references in code?

if the name of the sheet has been changed in VBA then just the name will work

Sheet2.activate

Keep in mind that the code name for the sheet and the name that appears on
the sheet tab may not be the same.
--
If this helps, please remember to click yes.


"Bassman62" wrote:

I have some old code that refers to sheet names and I'd like to change these
to the sheet code names.
However, apparently code names are objects of a different type than sheet
Names.
Here's an example of what I'm trying to do:
Change
ThisWorkbook.Sheets("Report").Activate
To
ThisWorkbook.Sheet2.Activate 'Error: Method or Data Member not
found.
This seems elementary but I can't seem to get the syntax correct.
How can I refence a code name of a particula workbook?
Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Change Sheet references in code?

Thanks for the reply.
I'd really like to use the sheet code name as the index will not follow if
the sheets are rearranged.
Also, I'd like to know how to refer to the sheet code name of a project that
is not the ActiveWorkbook.
Thanks.

"Paul C" wrote in message
...
Try

ThisWorkbook.Sheets(2).Activate

you can also eliminate the ThisWorkbook (it is implied)

Sheets(2).Activate
--
If this helps, please remember to click yes.


"Bassman62" wrote:

I have some old code that refers to sheet names and I'd like to change
these
to the sheet code names.
However, apparently code names are objects of a different type than sheet
Names.
Here's an example of what I'm trying to do:
Change
ThisWorkbook.Sheets("Report").Activate
To
ThisWorkbook.Sheet2.Activate 'Error: Method or Data Member not
found.
This seems elementary but I can't seem to get the syntax correct.
How can I refence a code name of a particula workbook?
Thanks.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Change Sheet references in code?

Thanks Paul.
After more research, I think that I cannot refer to sheet code names outside
of the active workbook.
Thanks again for the prompt reply.


"Paul C" wrote in message
...
if the name of the sheet has been changed in VBA then just the name will
work

Sheet2.activate

Keep in mind that the code name for the sheet and the name that appears on
the sheet tab may not be the same.
--
If this helps, please remember to click yes.


"Bassman62" wrote:

I have some old code that refers to sheet names and I'd like to change
these
to the sheet code names.
However, apparently code names are objects of a different type than sheet
Names.
Here's an example of what I'm trying to do:
Change
ThisWorkbook.Sheets("Report").Activate
To
ThisWorkbook.Sheet2.Activate 'Error: Method or Data Member not
found.
This seems elementary but I can't seem to get the syntax correct.
How can I refence a code name of a particula workbook?
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
Code to change code in a sheet and workbook module Otto Moehrbach Excel Programming 11 November 11th 07 07:20 PM
Import data using QueryTable somehow change sheet cells references JackCali Excel Programming 2 April 6th 07 05:34 PM
formula references change when data entry sheet is modified ExcelKat Excel Worksheet Functions 0 June 9th 06 12:07 AM
See code enclosed - Convert to formulas with absolute reference inculding the sheet references! Maria J-son Excel Programming 0 May 10th 05 08:40 AM
Code to change references Steve[_27_] Excel Programming 0 August 4th 03 11:43 PM


All times are GMT +1. The time now is 01:46 PM.

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"