Change Integer to string

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
640
I have a user form that a user inputs a series of numbers in a textbox1 (IE: 77234). I also have a cell with the same number.

When I try to compare ( if textbox1.value = Range ("A1").value .... one is an integer and one is a string and do not match .
How do I change the cell to a string or textbox to an integer.
I will need to change it back after I compare then.

Thank You
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,609
Office Version
  1. 365
Platform
  1. Windows
You could try
VBA Code:
If Clng(textbox1.value) = Range ("A1").value
to evaluate the textbox string as numeric without changing the type, however if the content of the textbox is not valid to convert to a number then it will result in a runtime error.
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,129,481
Messages
5,636,588
Members
416,927
Latest member
BNM8V6

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
Top