Consulting

Results 1 to 1 of 1

Thread: macro not working for if function

  1. #1
    VBAX Newbie
    Joined
    Nov 2012
    Posts
    1
    Location

    macro not working for if function

    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.

    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 macroThen the exisiting column J becomes column K and so on.
    What am I missing here?
    Hope you'll be able to help.
    Thanks.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •