0
votes

Ok, the problem is that im working in a excel userform, but i cannot find a way to do a comparation between a textbox value and a cell value and if some statement is meet it will write other value to another textbox (the program is has already been made with the use of excel macros, but i wanted to make it look better, and im trying to use the userform)

Here is the code i am trying to run

Select Case (TextBox1)
Case Is <= Sheet2.Cells(3, 8)
    TextBox21 = 4
End Select

(When you run the code its does nothing)

Do i need to do something else to make it work?, because im using the same excel file of my tables to make the userform,if i'm confusing something please do let me know.

Thanks for your answer and sorry for my English.

1

1 Answers

1
votes
If CInt(TextBox1.Value) <= CInt(Sheet1.Cells(1, 1).Value) Then  
    TextBox2.Value = 4
end if

The problem is that you are trying to compare strings, when you should be comparing numbers. You just need to convert the values to an int. You might also want to put in a little more validation to ensure that textBox1 and cells(1,1) are in fact numeric values.