ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text to Value (https://www.excelbanter.com/excel-programming/332563-text-value.html)

Steph[_3_]

Text to Value
 
Hi. I have a column of numbers. Before my code executes, I would like to
check the column to make sure all numbers are truly numbers. Every so often
a number slips in with a ' in front of it, making it text. Is there a
simple way to remove the ' in cells where it occurs? I tried to use
edit/replace, but MS said it could not find the '. Thanks!



K Dales[_2_]

Text to Value
 
You could do this in your code, if you want, e.g.
FixCell = Val(Trim(ActiveCell.Value))


"Steph" wrote:

Hi. I have a column of numbers. Before my code executes, I would like to
check the column to make sure all numbers are truly numbers. Every so often
a number slips in with a ' in front of it, making it text. Is there a
simple way to remove the ' in cells where it occurs? I tried to use
edit/replace, but MS said it could not find the '. Thanks!




dominicb[_36_]

Text to Value
 

Good evening Steph

This routine should get rid of the annoying ' and leave "proper"
numbers and formulae alone:

Sub TextNumber()
On Error Resume Next
For Each usrcell In Selection.Areas
usrcell.FormulaLocal = usrcell.FormulaLocal
Next
End Sub

Highlight the whole range(s) you want to check and then call the
macro.

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=381362


dick[_2_]

Text to Value
 


Steph wrote:
Hi. I have a column of numbers. Before my code executes, I would like to
check the column to make sure all numbers are truly numbers. Every so often
a number slips in with a ' in front of it, making it text. Is there a
simple way to remove the ' in cells where it occurs? I tried to use
edit/replace, but MS said it could not find the '. Thanks!


This happens often to me too. To ensure numbers, use the paste special
funtion to add a zero (yes, 0) to all of the suspect cells. This
converts all to real numbers.



All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com