Error 1004 with FormulaR1C1 **** Newbee, Help Please!!

amisagi

New Member
Joined
Apr 24, 2015
Messages
15
Hi, I am new to VB coding and deperately need help...
I have racked my brain but cant find the cause of error 1004 with this particualr line (highlighted in Red).

Dim X as Long
Dim iRow, iCol, intMonths As Integer

iRow = X * intMonths 'X is the number of rows in Sheet1 with data
iCol = intMonths - 2 ' I have a seperate module to calculate intMonths and it is working perfect.
Range("addrPerfCol")(RowToFill, 1) ' Works perfect, selects the correct row, column

ActiveCell.FormulaR1C1 = "=IFERROR(IF(Sheet1!R[-iRow]C[iCol]="""",""DNR"",IF(Sheet1!R[-iRow]C[iCol]>=Sheet1!R[-iRow]C8,""M"",""NM"")),"""")"

Many thanks in advance, if there is any other info required please let me know...
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
iRow and iCol are VBA variables that mean nothing to Excel, so your formula string needs to pass their values to Excel, like this:

Code:
Range("addrPerfCol")(RowToFill, 1).FormulaR1C1 = _
    "=IFERROR(IF(Sheet1!R[-" & iRow & "]C[" & iCol & "]="""",""DNR"",IF(Sheet1!R[-" _
    & iRow & "]C[" & iCol & "]>=Sheet1!R[-" & iRow & "]C8,""M"",""NM"")),"""")"

PS: Where's my manners? Welcome to the Forum!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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