Change Integer to string

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
633
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
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,419
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,127,199
Messages
5,623,317
Members
415,966
Latest member
ctorohuamanchumo

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