Results 1 to 2 of 2

Thread: Loop on Single cell

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Jun 2022
    Posts
    1
    Location

    Loop on Single cell

    Hi

    I’m relatively new to VBA and I’m currently stuck on creating a loop function. I have an IF statement (below) written. Where I need to increase a number (which is an option number) in the active cell until the criteria of another cell (4 to the right of active cell). I’ve had to use double rather than integer due to my value of the dependant cell (score) have decimals involved.

    Sub Name()
    Dim score As Double 
    score = ActiveCell.Offset(0,4).value
    If score >=2 Then
    ActiveCell = ActiveCell +1
    End If
    End Sub
    I have tried Do/Loop While score >= 2 and when the dependant cell starts on <2 it doesn’t add anything (which is correct) however when starting on a value >=2 it keeps the loop going even when a number <2 has come in the dependant cell

    Hope this all makes sense and appreciate any help
    Last edited by Aussiebear; 06-02-2022 at 11:52 AM. Reason: Added code tags to supplied code

Posting Permissions

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