Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Sheet CodeNames

Hi,

If I am using a worksheet codename, how would I use it in this formula?

Range("A10").Select
ActivateCell.formulaR1C1 = "='Mainsheet'!R10C22"

The sheet's code name is MainPage. I have tried leaving out the single
quotes i.e.

ActivateCell.FormulaR1C1 = "=MainPage!R10C22"

but it doesn't work. How would I use a sheet code name in this instance?

Thanks for your help.


  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Sheet CodeNames

Formulas don't refer to the code names. You could do this though:

Range("A10").FormulaR1C1 = "='" & Replace(MainPage.Name, "'", "''") &
"'!R10C22"




"Karen53" wrote in message
...
Hi,

If I am using a worksheet codename, how would I use it in this formula?

Range("A10").Select
ActivateCell.formulaR1C1 = "='Mainsheet'!R10C22"

The sheet's code name is MainPage. I have tried leaving out the single
quotes i.e.

ActivateCell.FormulaR1C1 = "=MainPage!R10C22"

but it doesn't work. How would I use a sheet code name in this instance?

Thanks for your help.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Sheet CodeNames

ActivateCell.FormulaR1C1 = "='" & MainPage.Name & "'!R10C22"

MainPage refers to the worksheet (code name) as you requested, and the
".Name" part is the property that returns the tab name (what the user
sees at the bottom of the worksheet). Be sure to include single quotes
around the sheet name, in case the sheet name has spaces in it. (Note
the single quote to the right of the second "=" and just to the left of
the "!".)
--
Regards,
Bill Renaud



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Sheet CodeNames

That will fail if there are single quotes in the sheet name. Better for the
OP to use what I posted in the event there are single quotes in the sheet
name, which need to be delimited.

Cheers
-

"Bill Renaud" wrote in message
. ..
ActivateCell.FormulaR1C1 = "='" & MainPage.Name & "'!R10C22"

MainPage refers to the worksheet (code name) as you requested, and the
".Name" part is the property that returns the tab name (what the user
sees at the bottom of the worksheet). Be sure to include single quotes
around the sheet name, in case the sheet name has spaces in it. (Note
the single quote to the right of the second "=" and just to the left of
the "!".)
--
Regards,
Bill Renaud





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Sheet CodeNames

Thanks to you both!

"-" wrote:

That will fail if there are single quotes in the sheet name. Better for the
OP to use what I posted in the event there are single quotes in the sheet
name, which need to be delimited.

Cheers
-

"Bill Renaud" wrote in message
. ..
ActivateCell.FormulaR1C1 = "='" & MainPage.Name & "'!R10C22"

MainPage refers to the worksheet (code name) as you requested, and the
".Name" part is the property that returns the tab name (what the user
sees at the bottom of the worksheet). Be sure to include single quotes
around the sheet name, in case the sheet name has spaces in it. (Note
the single quote to the right of the second "=" and just to the left of
the "!".)
--
Regards,
Bill Renaud








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Sheet CodeNames

<<That will fail if there are single quotes in the sheet name.
Excel 200 does not allow single quotes in the sheet name. Does Excel
2007 allow this?
--
Regards,
Bill Renaud



  #7   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Sheet CodeNames

My copies of XL2000 and XL2003 do allow single quotes. Always have.

"Bill Renaud" wrote in message
. ..
<<That will fail if there are single quotes in the sheet name.
Excel 200 does not allow single quotes in the sheet name. Does Excel
2007 allow this?
--
Regards,
Bill Renaud





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Sheet CodeNames

Strange. My copy of Excel 2000 (with SP3) does not allow quotes in
either the first or last character positions. It only allows them as
long as they are embedded in the middle of the tab name.

You are correct about needing to remove any single quotes from the sheet
name before using it in the formula.
--
Regards,
Bill Renaud



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
Loops with sheet codenames NEMB Excel Discussion (Misc queries) 0 February 13th 11 12:34 AM
codenames [email protected] Excel Programming 2 October 19th 06 08:44 PM
Codenames Bill[_30_] Excel Programming 3 September 8th 06 06:59 PM
Use of Sheet CodeNames to Select Sheet in Different Workbook Randy[_10_] Excel Programming 10 June 14th 05 04:55 AM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy Excel Discussion (Misc queries) 1 June 10th 05 12:17 AM


All times are GMT +1. The time now is 03:01 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"