Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Posts
    304
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with loop statement in Excel macro (Visual Basic 6.3 / Excel 2003)

    I no nothing about VB and my extent of "writing" macros is limited to what the Macro Recorder can record me doing.

    I'm trying to create a macro in Excel that would check IF cell C3 were empty. If not, it should copy/paste a formula from cell A2 to cell A3 AND copy/paste a formula from cell B2 to B3, then move on and check C4 to see if it's empty and repeat if necessary. If C3 were empty (or any subsequent row in C as it progresses), then it should stop. Can anyone help a flailing VB newbie?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need help with loop statement in Excel macro (Visual Basic 6.3 / Excel

    Does this do what you want?

    Sub Macro4Satiria()
    Dim oCell As Range
    ' Start in C3
    Set oCell = Range("C3")
    ' Loop while cell is not blank
    Do While Not oCell = ""
    ' Fill down the cells one row up, in the two colums to the left
    oCell.Offset(-1, -2).Resize(2, 2).FillDown
    ' Move one row down
    Set oCell = oCell.Offset(1, 0)
    Loop
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Posts
    304
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need help with loop statement in Excel macro (Visual Basic 6.3 / Excel

    Hans, as usual your words are golden. That worked like a charm. - Satiria

Posting Permissions

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