Macros in my spreadsheet

Closed
artyguns Posts 1 Registration date Thursday November 15, 2012 Status Member Last seen November 15, 2012 - Nov 15, 2012 at 03:53 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Nov 26, 2012 at 09:58 AM
Hello,

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.
I need this to populate for all the respective rows as well.
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.

when I click on the command button, the cell J3 is not updated with the formula. There's already data in this cell.

I have to create the formula so that there's another value in this cell when I run the macro. then the existing column J becomes column K and so on.

What am I missing here?

Hope you'll be able to help.




Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Nov 26, 2012 at 09:58 AM
Hi Artyguns,

Not clear to me.

You want to fill certain cells with formula's and then autofill those formula's down.
How far down?


quote
when I click on the command button, the cell J3 is not updated with the formula
unquote

What is the deal here, put formula in J3 or not?


quote
I have to create the formula so that there's another value in this cell when I run the macro
unquote

Are we still talking about J3?, what will the formula be?


quote
then the existing column J becomes column K and so on.
unquote

By this you mean to insert a column before column J, making all the formula's move a column to the right?


Best regards,
Trowa
0