Office Software Thread, Converting text to number in Technical; SIMs exports numeric data to Excel as text (very helpful). Normally, for my own use, I just convert it to ...
26th May 2009, 05:31 PM #1
- Rep Power
Converting text to number
SIMs exports numeric data to Excel as text (very helpful). Normally, for my own use, I just convert it to numeric using Excels error checking feature. However, I need to write a report for another member of staff and so want to automate this convertion process using a macro. Does anyone know what VBA code I could use to do this.
IDG Tech News
26th May 2009, 08:24 PM #2
You can use Excel to generate a Macro for you just by doing what you would usually do and recording it - it'll generate it as viewable VBA and you can haxxor it should you feel the need.
I'm not big on reports from SIMS, but can you not just highlight the column/rows and change the formatting options from text to numerical (or whatever type you want)?
26th May 2009, 08:40 PM #3
- Rep Power
Tried that already but it doesn't record error checking for some reason. Thanks anyway
26th May 2009, 08:49 PM #4
Select the text , right click, format cells, change to number. Should be able to get a macro to do that. Is that what you wanted to do?
26th May 2009, 09:19 PM #5
depending on what numerical data type you wanted to convert to
Excel VBA Type Conversion Functions. Convert Numbers to Text & Text to Numbers
converting to int
You could alter the above to something like so
Dim vStr, intNum
vStr = "1000.5"
intNum = CInt(vStr)
Otherwise as per above just use a macro to record it by formatting the cell into a number type cell
Sub ConvertToInteger(byval intNumber)
intNum = CInt(intNumber)
ConvertToInteger = intNum
By russdev in forum Hardware
Last Post: 12th February 2010, 04:16 PM
By strawberry in forum Windows
Last Post: 30th March 2008, 02:38 PM
By paulpmp4 in forum How do you do....it?
Last Post: 16th February 2008, 12:48 PM
By goodhead in forum Windows
Last Post: 14th March 2007, 02:37 PM
By Samson in forum Windows
Last Post: 12th March 2007, 10:15 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)