Avatar of RWayneH
RWayneH
Flag for United States of America asked on

Concatinating with variable name.

I have been trying to concatenate a named ref with a cell and it is not working...  any ideas?

PO = ActiveCell.Value
            ActiveCell.Offset(0, -5).Select
            ActiveCell.FormulaR1C1 = "=CONCATENATE(PO,""/"",RC[-1])"

Open in new window


If PO is:  123456789   and RC[-1] is  3000   I am looking to get:  123456789/3000
VBAMicrosoft Excel

Avatar of undefined
Last Comment
RWayneH

8/22/2022 - Mon
Shums Faruk

Hi RWayneH,

Try below:
ActiveWorkbook.Names.Add Name:="PO", RefersToR1C1:=ActiveCell
ActiveCell.Offset(0, -5).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(PO,""/"",RC[-1])"

Open in new window


If you can provide me the exact cells, I can write a code, then you don't need to use ActiveCell
RWayneH

ASKER
I really need to use ActiveCell in this case....  are you saying this cannot be done?  Your Ln1 will not work, because it is in a While Loop and the value of PO chg's throughout the loop.
RWayneH

ASKER
Rather than get into redesigning the whole Do While.... I would like to be able to use a named reference for an ActiveCell in the concatenation.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SOLUTION
Shums Faruk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Subodh Tiwari (Neeraj)

You should try it like this....
Dim PO As Range
Set PO = ActiveCell
ActiveCell.Offset(0, -5).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(" & PO.Address(ReferenceStyle:=xlR1C1) & ",""/"",RC[-1])"

Open in new window

ASKER CERTIFIED SOLUTION
Subodh Tiwari (Neeraj)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
RWayneH

ASKER
Appreciate the help.  Thanks