Textbox doesn't seem to recognize that it has the same value as the cell!

Oliver Dewar

Board Regular
Joined
Apr 17, 2011
Messages
201
OK I've come across one extremely odd case for the X(cel)-files.

This is something I have done over and over in this project except for one difference... this cell has a formula in it, not just a value as in the others.

in the cell in question I have a formula that works well. Here's the formula:
Code:
=IF($Y39="","",IF($Y39="Child","Child",IF($Y39="Adult","Adult",DATEDIF($Z39,TODAY(),"y")+$Y39)))
this code works out the age of someone from a number and date of input or the words Child or Adult.

the cell in question (A1) returned 13.

in textbox1 on a userform I have a textbox1_change as follows:

Code:
Textbox1_change()
if textbox1.value = range("A1").value then
msgbox"match"
End if
End Sub

I type in the number 13 into textbox1 and... nothing happens!

Now, I have found a workaround in that I copy the value of the formula to another cell on the sheet and the contents of the textbox to the next cell and compare those... and it works!

So really my question is... what is going on? Why doesn't 13 in textbox1 = 13 (the result of the formula) in cell A1?

Any Moulders out there? :confused:
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Textboxes contain text not numbers. Try

Code:
If Val(textbox1.Value) = Range("A1").Value Then
 
Upvote 0
Well the result of the formula might be a number, like 13 for an example.

Textbox's hold text, so comparing them might not work.
Code:
If Val(TextBox1.Value) = Range("A1").Value Then
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top