Change Integer to string

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
692
Office Version
  1. 365
Platform
  1. Windows
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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