Insert apostrophe in VBA code as part of formula

mosiki

Board Regular
Joined
Oct 29, 2008
Messages
175
Hi

I wish to use VBA code to insert a formula into a spreadsheet. line of code below:

PHP:
wsREC.Cells(j, lPosRecBrokMVCol).FormulaR1C1 = "=MATCH(RC[-6],INDIRECT(" ' "&RC[-7]&" Positions"&"'!k:k"),0)"

Problem is that the ' in between the "" is commenting the remainder of the line of code. is there any way to prevent this?

Thanks

Mosiki
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I want the code to put in the formula:

=MATCH(RC[-6],INDIRECT("'"&RC[-7]&" Positions"&"'!k:k"),0)
 
Upvote 0
Try:

Code:
wsREC.Cells(j, lPosRecBrokMVCol).FormulaR1C1 = "=MATCH(RC[-6],INDIRECT(""'""&RC[-7]&"" Positions""&""'!k:k""),0)"

The easiest way to get the syntax is to record a macro while entering the formula.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,711
Members
452,939
Latest member
WCrawford

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