Need help with this code, it counts only the second after "And".And if it possible to do like if cell("2.3")<point
reenter
else
Range..
Is it possible to do aritmetics with cells or do smth with other operators?

Sub hugo()
    Dim point As Double

    InputBox ("Enter The Closing Point(Between 1.1-1.6)")

    If point >= 1.1 And point < 1.6 Then
        MsgBox ("Reenter point")
        InputBox ("Enter The Closing Point")
    Else
        Range("D25").Value = InputBox("Enter The Closing Point(Between 1.1-1.6)")
    End If
End Sub

Recommended Answers

All 3 Replies

In excel math between cells is handled by functions. Any regular math can easily be done, adding, subtracting, multiplying, dividing, between individual cells and/or range of cells. More complicated math can also be accomplished but the learning curve goes up lol.

Public Sub EnterTheSum()
Dim strsum As String

strsum = Application.InputBox("Enter the sum")
If (strsum > 5000) Then
MsgBox ("Reenter sum")
strsum = Application.InputBox("Enter the sum")
Range("C5").Value = strsum
Else
Range("C5").Value = strsum

End If
End Sub

Tricky little excel.what to do if vba ignores else statement?I know this code is wrong ,but it works -until second wrong input, and "else ".Yesterday was ok, now i have to do my project from the begining...

Try this. Some of the syntax might not be 100% but you should be able to figure it out. 'strsum starts out with a value of 5000 but the while loop will trap it until it changes.

Dim strsum as string = 5000
while strsum >= 5000
    strsum = Application.InputBox("Enter the sum(under 5000)")
endwhile
Range("C5").Value = strsum
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.