Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Macro - Fixed text code needs replacing with variable text

I would like to change the below code so that all of the current fixed text
typed "Sheet1" are replaced with a variable text and the variable text is
equal to the ActiveSheet.Name

I can see there are two parts too resolving this 1) the variable text will
be only part of the define name and 2) the variable text in the formula entry
within the define name

Any help with this would be fantastic
Many thanks
Steve

ActiveWorkbook.Names.Add Name:="Oracle_Travel_Sheet1", RefersToR1C1:= _
"=OFFSET(Sheet1!R12C2,0,0,COUNTA(Sheet1!C2),COUNTA (Sheet1!R12))"
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Macro - Fixed text code needs replacing with variable text

Try this (untested):

myName = ActiveSheet.Name
ActiveWorkbook.Names.Add Name:="Oracle_Travel_" & myName, RefersToR1C1:= _
"=OFFSET(myName & !R12C2,0,0,COUNTA(myName & !C2),COUNTA(myName &
!R12))"


HTH
knut


"steven.holloway" skrev i melding
...
I would like to change the below code so that all of the current fixed text
typed "Sheet1" are replaced with a variable text and the variable text is
equal to the ActiveSheet.Name

I can see there are two parts too resolving this 1) the variable text will
be only part of the define name and 2) the variable text in the formula
entry
within the define name

Any help with this would be fantastic
Many thanks
Steve

ActiveWorkbook.Names.Add Name:="Oracle_Travel_Sheet1", RefersToR1C1:= _
"=OFFSET(Sheet1!R12C2,0,0,COUNTA(Sheet1!C2),COUNTA (Sheet1!R12))"



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro - Fixed text code needs replacing with variable text

Dim ShtName as string
shtname = "Sheet1"

ActiveWorkbook.Names.Add Name:="Oracle_Travel_" & shtname, _
RefersToR1C1:="=OFFSET('" & shtname & "'!R12C2,0,0," _
& "COUNTA('" & shtname & "'!C2),COUNTA('" & shtname & "'!R12))"

But there are some characters that can't be used in the name:= portion. You'll
want to be careful.

The apostrophes inside the referstor1c1:= portion will let any valid name work
there.



steven.holloway wrote:

I would like to change the below code so that all of the current fixed text
typed "Sheet1" are replaced with a variable text and the variable text is
equal to the ActiveSheet.Name

I can see there are two parts too resolving this 1) the variable text will
be only part of the define name and 2) the variable text in the formula entry
within the define name

Any help with this would be fantastic
Many thanks
Steve

ActiveWorkbook.Names.Add Name:="Oracle_Travel_Sheet1", RefersToR1C1:= _
"=OFFSET(Sheet1!R12C2,0,0,COUNTA(Sheet1!C2),COUNTA (Sheet1!R12))"


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Macro - Fixed text code needs replacing with variable text

Thanks DS & Dave, exactly what I needed.

Many thanks again
Steve

"Dave Peterson" wrote:

Dim ShtName as string
shtname = "Sheet1"

ActiveWorkbook.Names.Add Name:="Oracle_Travel_" & shtname, _
RefersToR1C1:="=OFFSET('" & shtname & "'!R12C2,0,0," _
& "COUNTA('" & shtname & "'!C2),COUNTA('" & shtname & "'!R12))"

But there are some characters that can't be used in the name:= portion. You'll
want to be careful.

The apostrophes inside the referstor1c1:= portion will let any valid name work
there.



steven.holloway wrote:

I would like to change the below code so that all of the current fixed text
typed "Sheet1" are replaced with a variable text and the variable text is
equal to the ActiveSheet.Name

I can see there are two parts too resolving this 1) the variable text will
be only part of the define name and 2) the variable text in the formula entry
within the define name

Any help with this would be fantastic
Many thanks
Steve

ActiveWorkbook.Names.Add Name:="Oracle_Travel_Sheet1", RefersToR1C1:= _
"=OFFSET(Sheet1!R12C2,0,0,COUNTA(Sheet1!C2),COUNTA (Sheet1!R12))"


--

Dave Peterson

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
Entering Variable Text in Text Boxes...... Steve Jones Excel Discussion (Misc queries) 3 June 14th 07 02:34 PM
replacing text in all cells with existing text plus something avi2001 Excel Discussion (Misc queries) 2 November 2nd 05 04:29 PM
Replacing #N/A with other text Dave Excel Worksheet Functions 2 August 11th 05 11:27 PM
Help replacing text with Yes or No Jerry Arnone, PMP Excel Discussion (Misc queries) 6 June 24th 05 02:05 AM
Putting text in a column based on variable text from another colum Jacky D. Excel Discussion (Misc queries) 1 December 16th 04 06:09 PM


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