IF Function in VBA

I managed to create a macro to show the following:

If (I3<>0,I3*G3,H3*G3) and this repeats itself for cell N3,R3, V3,Z3 ETC.

Option Explicit
Sub Eg()
Range("J3, N3,R3, V3,Z3,AD3,AH3,AL3,AP3,AT3,Ax3,BB3,XF3,BJ3").Formula = "=IF(RC[-1]<>0,RC[-1]*RC[-3],RC[-2]*RC[-3])"
End Sub

Let me explain a bit more how this should work:

This report needs to be downloaded from an application.
The macro needs to be attached to this report so that when I download the report the macro automatically runs this formula in the appropriate columns.

Also I 'll have to populate the spreadhseet for all the rows with this formula.

The columns where the formula should sit are not blank but this needs to be catered for in the report automatically once the macro is run.

What am I missing here?

Hope you'll be able to help.

Thanks.

AttachmentSize
Example_Actual_Spend_on_Time_Sheet_16_11_v1.xls40.5 KB

Hum, I don't understand. What

Hum, I don't understand.
What do you want to mean by « but only for the first row »

What I can understand is that it's the entire range of column that need to be converted...
Is it possible you upload an sample of your workbook into a shared site ?

IF Function VBA

ok do you have a shared site in mind?

or I can send by email?

I noticed something ARgy...

The columns with the code in is overriding the exisiting data in that column.

It shouldn't do that. it should move the columns to the right and have the empty columns with the code in....

IF Function VBA

In other words a new column should be inserted after J3,N3,R3,V3,Z3,AD3,AH3,AL3,AP3,AT3,AX3,BB3,BF3,BJ3 to have the new code.

IF Function VBA

Hi Argy

I have attached an example of my file. Hope you can download it.

Thanks

Silky

No, sorry. Where do I can get

No, sorry.
Where do I can get your file ?

File attachment

Hi,

The file attachment is in the end of the current topic explanation section.

 

Best regards.

IF Function VBA

I attached it on the edit tab.....let me know if you can't find it otherwise i'll send you by email...

I cannot find the topic you

I cannot find the topic you mean.
You can send by mail here :
techxlsupport@yopmail.com

IF Function in VBA

Argy
I have sent you the doc in an email.

Ok, I received the file... As

Ok, I received the file...
As I see the content, do I have to understand that you want the formula must be applied between the rows #3 and #22
?
I'm in doubt because the column J contains some amounts specified in red. Do you want to replace the red value by the formula according to the relative row ?

Can you explain what you expect now ?