Coding

  • Thread starter Thread starter eenglish
  • Start date Start date
E

eenglish

What would be the correct code for the following macro:

Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] > [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up
 
What would be the correct code for the following macro:
Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] > [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up

What about if [B13] = [D3]? Or was that what you meant to type for your last
If..Then statement? Assuming that is what you meant, try this...

[D13] = [D5] - ([B13] < [D3] + 1)

Rick Rothstein (MVP - Excel)
 
What would be the correct code for the following macro:
Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] > [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up

What about if [B13] = [D3]? Or was that what you meant to type for your
last If..Then statement? Assuming that is what you meant, try this...

[D13] = [D5] - ([B13] < [D3] + 1)

Actually, in looking at what you wrote more carefully, I think you might
actually want this (I'm assuming your numbers are always whole numbers)...

[D13] = [D5] - (([B13] < [D3] + 1) And ([B13] <> 0))

Rick Rothstein (MVP - Excel)
 
Back
Top