Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default using the value of a macro variable in a concatenate formula

I've a macro that writes a CONCATENATE formula into a cell of an output
sheet. Could anyone tell me how i could incorporate the value of a
string variable created elsewhere in the macro as part of the formula?
At the moment i have something like the following, which gives me a
?#NAME error. It works with the first three elements of the concatenate
formula i.e. if I remove NameStr).
Thanks very much.



Dim NameStr As string

[NameStr is set elsewhere in the macro]
[DestSh is the output worksheet]

DestSh.Cells(3, "b").FormulaR1C1 = _
"=CONCATENATE(R[1]C,""_"",RC[-1],NameStr)"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default using the value of a macro variable in a concatenate formula

DestSh.Cells(3, "b").FormulaR1C1 = _
"=CONCATENATE(R[1]C,""_"",RC[-1]," & NameStr & ")"

HIH
--
AP

"Simon W" a écrit dans le message de
oups.com...
I've a macro that writes a CONCATENATE formula into a cell of an output
sheet. Could anyone tell me how i could incorporate the value of a
string variable created elsewhere in the macro as part of the formula?
At the moment i have something like the following, which gives me a
?#NAME error. It works with the first three elements of the concatenate
formula i.e. if I remove NameStr).
Thanks very much.



Dim NameStr As string

[NameStr is set elsewhere in the macro]
[DestSh is the output worksheet]

DestSh.Cells(3, "b").FormulaR1C1 = _
"=CONCATENATE(R[1]C,""_"",RC[-1],NameStr)"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default using the value of a macro variable in a concatenate formula

Try this...


DestSh.Cells(3, "b").FormulaR1C1 = _
"=CONCATENATE(R[1]C,""_"",RC[-1]," & NameStr & ")"



"Simon W" wrote:

I've a macro that writes a CONCATENATE formula into a cell of an output
sheet. Could anyone tell me how i could incorporate the value of a
string variable created elsewhere in the macro as part of the formula?
At the moment i have something like the following, which gives me a
?#NAME error. It works with the first three elements of the concatenate
formula i.e. if I remove NameStr).
Thanks very much.



Dim NameStr As string

[NameStr is set elsewhere in the macro]
[DestSh is the output worksheet]

DestSh.Cells(3, "b").FormulaR1C1 = _
"=CONCATENATE(R[1]C,""_"",RC[-1],NameStr)"


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default using the value of a macro variable in a concatenate formula

thanks for the reply - unfortunately it gives me an 'application
defined of object defined error'. The concatenate formula works without
" & NameStr & " and NameStr is defined as i can put it into a different
cell not as part of the concatenate formula. Very grateful for any
suggestions.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default using the value of a macro variable in a concatenate formula

I guess NameStr has been defined as a name on the worksheet.
If this is true, use Range(Namestr).value instead

HTH
--
AP

"Simon W" a écrit dans le message de
ups.com...
thanks for the reply - unfortunately it gives me an 'application
defined of object defined error'. The concatenate formula works without
" & NameStr & " and NameStr is defined as i can put it into a different
cell not as part of the concatenate formula. Very grateful for any
suggestions.



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
Concatenate Variable Array of Text Cells atryon Excel Discussion (Misc queries) 3 August 29th 08 11:57 PM
Macro - Formula RC[?] with ? being a variable number steven.holloway Excel Discussion (Misc queries) 5 July 18th 08 10:07 AM
Concatenate column with variable to set a range april Excel Discussion (Misc queries) 2 November 26th 07 03:26 PM
Macro Sum Formula For a Variable Rang Sid Excel Programming 2 October 18th 05 09:58 PM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM


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