• VBA Solution Needed

    Author
    Topic
    #462201

    How would I write a macro to insert the results of the formula below into Cell G10. I need to return the number of days between today and the date entered in E10.
    I also need it to be a “change event”. I think!

    =IF(E10=””,””,NOW()-E10)

    Viewing 1 reply thread
    Author
    Replies
    • #1175506

      You can use code like this:

      Code:
      Sub MyMacro()
        Range("G10").Formula = "=IF(E10="""","""",TODAY()-E10)"
      End Sub

      Note that the quotes within the formula have been doubled. This is necessary whenever you need quotes within a quoted string in code.

    • #1175511

      Thanks

    Viewing 1 reply thread
    Reply To: VBA Solution Needed

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: