Help with variable inside formula

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
440
Office Version
  1. 2016
Hey guys i have the following

ActiveCell.FormulaR1C1 = _
"=+IF(OR(RC[-20]=""CO SAR_" & ThisWorkbook.Worksheets("Variables").Range("A7").Value & ".xlsx"", RC[-20]='" & ThisWorkbook.Worksheets("Variables").Range("A2").Value & " CO IPAC " & "(DSSN 3801)" & ".xlsx""),""X"","" "")"


something is wrong with this section as its the only section i changed. I cant figure out the syntax for inserting a variable into formulas

RC[-20]='" & ThisWorkbook.Worksheets("Variables").Range("A2").Value & " CO IPAC " & "(DSSN 3801)" & ".xlsx""),""X"","" "")"

error object not defined

Can you guys help me correct it?

Jordan
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Your quotes are not right in the line above "error object not defined".

Instead of single quote then double quote, I think it should be three double quotes.

Try:
Code:
ActiveCell.FormulaR1C1 = _
"=+IF(OR(RC[-20]=""CO SAR_" & ThisWorkbook.Worksheets("Variables").Range("A7").Value & ".xlsx"", RC[-20]=""" & ThisWorkbook.Worksheets("Variables").Range("A2").Value & " CO IPAC " & "(DSSN 3801)" & ".xlsx""),""X"","" "")"
 
Upvote 0
Solution
Your quotes are not right in the line above "error object not defined".

Instead of single quote then double quote, I think it should be three double quotes.

Try:
Code:
ActiveCell.FormulaR1C1 = _
"=+IF(OR(RC[-20]=""CO SAR_" & ThisWorkbook.Worksheets("Variables").Range("A7").Value & ".xlsx"", RC[-20]=""" & ThisWorkbook.Worksheets("Variables").Range("A2").Value & " CO IPAC " & "(DSSN 3801)" & ".xlsx""),""X"","" "")"
awesome thanks a bunch OAKTREE! Worked great!
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,164
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top