Problem Implementing ActiveCell.FormulaR1C1 in VBA (with string)

MickFlanagen

New Member
Joined
Jan 24, 2012
Messages
27
Good Morning,

I've done all kinds of searching, around this message board and other places, and I cannot figure out why I am getting an error here:

Code:
 ActiveCell.FormulaR1C1 = "=(IF(ISERROR(VLOOKUP($B6," & [I]Qtwo[/I] & "$C$2:$BE$92,54,FALSE)),""No Data"",VLOOKUP($B6," & [I]Qtwo[/I] & "!$C$2:$BE$92,54,FALSE)))"
For the record qtwo is defined using a text box much earlier in the code:

Code:
    Dim qone As String
    Dim qtwo As String
    
    qone = InputBox("Enter the factor name", "factor name")
    qtwo = InputBox("Enter Shortname", "short name")
           
    Selection.AutoFilter Field:=1, Criteria1:=qone
          
    Sheets.Add(Type:="C:\Documents and Settings\rutadav\Application Data\Microsoft\Templates\WB Data Template").Name = qtwo
The error I am getting is "Run-timer error '1004': Application-defined or object defined error"

Any help is appreciated.

Thanks,

Mick
 
1.) Missing an exclamation mark !
Code:
ActiveCell.FormulaR1C1 = "=(IF(ISERROR(VLOOKUP($B6," & Qtwo & "[COLOR="Red"]![/COLOR]$C$2:$BE$92,54,FALSE)),""No Data"",VLOOKUP($B6," & Qtwo & "!$C$2:$BE$92,54,FALSE)))"

2.) If Qtwo contains a space within the string, the sheet name within the formula has to be surrounded by single quotes e.g.
'My Sheet'!$C$2:$BE$92
 
Upvote 0

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