+ Reply to Thread
Results 1 to 2 of 2

changing cell formula part of macro

  1. #1
    Registered User
    Join Date
    06-15-2005
    Posts
    39

    changing cell formula part of macro

    Hello. I have a program with a simple macro I am trying to make. Here is the macro right now, it works fine as is: (I have highlighted in bold what I would like to change)

    Sub RequiredDate()
    Dim rizange, rizaange, a_range, b_range, As Range
    Set rizange = Range("H2:H8")
    Set rizaange = Range("I2:I8")
    For Each a_range In rizange
    If a_range <> "" Then
    Range("j" & a_range.Row).Select
    ActiveCell.Formula = "=E2+10"
    End If
    Next

    For Each b_range In rizaange
    If b_range <> "" Then
    Range("j" & b_range.Row).Select
    ActiveCell.Formula = "=E2+15"
    End If
    Next
    End Sub


    I would like to change the cell formula part of the macro. Instead of all of them being E2 plus a number, I would like it to be E2, then E3, then E4, etc etc. But when I try to replace what I have with something like:
    ="("e" & b_range.Row)+15" it gives me an error. Is there a way that I can fix this?

    Thanks for your help.

    -Steve

  2. #2
    Registered User
    Join Date
    07-27-2005
    Posts
    24
    CORRECTION: I think this will get you started in the right direction....

    Sub RequiredDate()

    Dim i As Long

    For i = 2 To 8
    If Cells(i, "H").Value <> "" Then
    Cells(i, "J").Formula = "=E" & (i) & "+10"
    End If
    Next

    End Sub
    Last edited by mthomas; 08-12-2005 at 05:56 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1