I am using a user form to get some data from the user.
Below is - essentially - the code. It is triggered when you click an OK-button on the form. The idea is that the code should compare the value that the user has entered into txtMyBox (if any) with the old (current) value that I have placed in a label called lblOldValue. If they are not the same, then the new value should be transferred to a range called MyRangeName:
If txtMyBox.Value <> lblOldValue.Caption Then
Range("MyRangeName").Value = txtMyBox.Value
End If
At first, everything seems to work. The new value is actually transferred into MyRangeName. The problem occurs when another cell than MyRangeName tries to use this data. What it gets then is the value, but as text. And since there are formulas who tries to do calculcation with whatever is in this other cell, a VALUE ERROR occurs.
I first used txtMyBox.Text, but I thought - hoped - that that was the problem, so I changed txtMyBox.Text to txtMyBox.Value, but to no avail.
If someone has the time to write a comment, it would be very appreciated.
Thanks
Bengt
Below is - essentially - the code. It is triggered when you click an OK-button on the form. The idea is that the code should compare the value that the user has entered into txtMyBox (if any) with the old (current) value that I have placed in a label called lblOldValue. If they are not the same, then the new value should be transferred to a range called MyRangeName:
If txtMyBox.Value <> lblOldValue.Caption Then
Range("MyRangeName").Value = txtMyBox.Value
End If
At first, everything seems to work. The new value is actually transferred into MyRangeName. The problem occurs when another cell than MyRangeName tries to use this data. What it gets then is the value, but as text. And since there are formulas who tries to do calculcation with whatever is in this other cell, a VALUE ERROR occurs.
I first used txtMyBox.Text, but I thought - hoped - that that was the problem, so I changed txtMyBox.Text to txtMyBox.Value, but to no avail.
If someone has the time to write a comment, it would be very appreciated.
Thanks
Bengt