gally
06-02-2022, 10:56 AM
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
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