Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variable through String 1

Status
Not open for further replies.

Bass71

MIS
Jun 21, 2001
79
Hi,

I need to have a variable within a string. Are strings flexible enough to handle this? Instead of writing R2C4, I tried R + var + C4 but the output still treats it as text.

Range("J2").Select
Dim var As Variant
var = 2
Do Until ActiveCell(2, 0).Value = "0.395833333333333"
ActiveCell.FormulaR1C1 = _
"=IF(RC[-6]> R + var + C4 ,""Look"","""")"
ActiveCell.Offset(1, 0).Select
Loop

Thanks for your help.............RO
 
=IF(RC[-6]>R" & var & "C4,""Look"","""")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well I still Run-Time Error 1004 - object defined error. For some reason, it will not accept the quotes and if I take them out the output in excel sheet shows the '&' as part of the formula
 
Can you please the EXACT line of code highlighted ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This line of code is what VB editor in Excel Macro does not like. (The first version I shortened formula for sake of simplicity)

ActiveCell.FormulaR1C1 = _
"=IF(OR(RC[-6]> R " & var & " C4*1.0055,RC[-6]< R + " & var & " C4/1.0055),""Look"","""")"


RO
 
=IF(OR(RC[-6]>R" & var & "C4*1.0055,RC[-6]<R" & var & "C4/1.0055),""Look"","""")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top