Quotes are confusing, even after looking at various examples, didn't seem to get it working until now. Hope is useful...
Using vlookup to get a title from another sheet. This is working. I have put into vba so that when a new csv file is ready, it will reformat to excel and insert the formula:
[tt]
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-3],[SurveyFilterMacro_NoTitle.xlsm]Titles!R3C3:R949C4,2,FALSE)"
[/tt]
To refine it, would like to remove all text after the pipe | symbol. No problem manually adjusting the formula in the cells, however, in VBA seems to have a problem with the pipe and quotes. For whatever reason multiple quotes still seemed to get an error. I also tried using Chr(124) and no luck. Since I tried doubling the quotes directly in the formula and it didn't work, I didn't think it would work as a standalone variable, however, turned out that in the variable the extra double quotes before and after chr(34) worked.
If there is a better way to write, I'm open to recommendations.
Using vlookup to get a title from another sheet. This is working. I have put into vba so that when a new csv file is ready, it will reformat to excel and insert the formula:
[tt]
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-3],[SurveyFilterMacro_NoTitle.xlsm]Titles!R3C3:R949C4,2,FALSE)"
[/tt]
To refine it, would like to remove all text after the pipe | symbol. No problem manually adjusting the formula in the cells, however, in VBA seems to have a problem with the pipe and quotes. For whatever reason multiple quotes still seemed to get an error. I also tried using Chr(124) and no luck. Since I tried doubling the quotes directly in the formula and it didn't work, I didn't think it would work as a standalone variable, however, turned out that in the variable the extra double quotes before and after chr(34) worked.
Code:
stFind = "" & Chr(34) & " |" & Chr(34) & ""
ActiveCell.FormulaR1C1 = _
"=LEFT(VLOOKUP(RC[-3],[SurveyFilterMacro_NoTitle.xlsm]Titles!R3C3:R949C4,2,FALSE),FIND(" & stFind & ",VLOOKUP(RC[-3],[SurveyFilterMacro_NoTitle.xlsm]Titles!R3C3:R949C4,2,FALSE),1) - 1)"
If there is a better way to write, I'm open to recommendations.