Please help to solve this

Amiko

New Member
Joined
Mar 15, 2014
Messages
1
Hi
I have a repetitive task that i am trying to slove by a macro.
I have a cell with a number - lets say cell N4 = 5782.3
Now i would like to change the B4 Cell content to =IF($K4<>0,5728.3,0)

How do i do it?
I have tried the following:
Dim a As Double
a = ActiveCell.Value
ActiveCell.FormulaR1C1 = "=IF(RC4<>0,a,0)"
ActiveCell.Offset(1, 0).Range("A1").Select

But then i get in the cell IF($K4<>0,a,0)

Thanks
Amy
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
try this RC[9] IS the cell on same row and 9 cols over from B4 (ie k4) rc[12] is the cell same row and 12 cols over from b4 (ie n4)
no need to select b4 the code sets the formula without selecting the cell

sub amiko1()

Range("b4").Formula = "=IF(RC[9]<>0,RC[12],0)"
end sub



Thanks
Amy[/QUOTE]
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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