VBA syntax to write formula to sheet

BDrew

Board Regular
Joined
Jun 8, 2008
Messages
79
I am attempting to add this formula to the Table of Contents: sheetname("TOC") in column D for a looping routine.
=MATCH("Ω",INDIRECT("'"&TOC!B4&"'!A:A"),1)

I must change "Ω" to ChrW(937) and TOC!B4 to TOC!B & NewRow so that I can increment NewRow=NewRow+1

TOC.Range("D" & NewRow).Formula = "=MATCH(" & ChrW(937) & ",INDIRECT(" & "" &"'TOC!B" & NewRow & "'!A:A"),1)"

the problem starts at INDIRECT(" which excel VBA considers an ending quote and attempting to put more quotes around that isolates the next problem at
'TOC!B which is considered as a note and not part of the formula.

Any assistance would be appreciated.

Brendan
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try

Code:
.Formula = _
        "=MATCH(""" & ChrW(937) & """,INDIRECT(""'""&TOC!B" & NewRow & "&""'!A:A""),1)"
 
Upvote 0
@sericom, can you actually get the Ω symbol to remain the same in the VBE as I get it changing to ? and so to directly apply it across the range rather than loop I need to do

Code:
Range("D3:D20").Formula = "=MATCH("""[COLOR="#FF0000"] & ChrW(937) & [/COLOR]""",INDIRECT(""'""&TOC!B4&""'!A:A""),1)"
 
Upvote 0
You're right, it doesn't hold, I was just showing how to sort the OP quote issue.
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

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