+ Post New Thread
Results 1 to 5 of 5
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 ...
  1. #1

    Join Date
    Sep 2008
    Location
    Newcastle upon Tyne
    Posts
    17
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    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.

    Cheers

  2. #2
    DrPerceptron's Avatar
    Join Date
    Dec 2008
    Location
    In a house
    Posts
    926
    Thank Post
    34
    Thanked 134 Times in 114 Posts
    Rep Power
    41
    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)?

  3. #3

    Join Date
    Sep 2008
    Location
    Newcastle upon Tyne
    Posts
    17
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Tried that already but it doesn't record error checking for some reason. Thanks anyway

  4. #4


    Join Date
    Sep 2007
    Location
    UK
    Posts
    5,448
    Thank Post
    1,447
    Thanked 889 Times in 570 Posts
    Rep Power
    647
    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?

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,786
    Thank Post
    3,282
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365
    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
    Code:
    Sub ConvertToInteger()
    
    Dim vStr, intNum
    
    
    
    vStr = "1000.5"
    
    intNum = CInt(vStr)
    
    MsgBox intNum
    
    
    End Sub
    
    You could alter the above to something like so

    Code:
    Sub ConvertToInteger(byval intNumber)
    
    Dim intNum
    
    intNum = CInt(intNumber)
    
    ConvertToInteger = intNum
    
    End Sub
    Otherwise as per above just use a macro to record it by formatting the cell into a number type cell

SHARE:
+ Post New Thread

Similar Threads

  1. Converting to ups
    By russdev in forum Hardware
    Replies: 13
    Last Post: 12th February 2010, 03:16 PM
  2. converting wmv for ipod
    By strawberry in forum Windows
    Replies: 5
    Last Post: 30th March 2008, 01:38 PM
  3. Converting to DivX
    By paulpmp4 in forum How do you do....it?
    Replies: 8
    Last Post: 16th February 2008, 11:48 AM
  4. converting vhs
    By goodhead in forum Windows
    Replies: 1
    Last Post: 14th March 2007, 01:37 PM
  5. converting an old domain server
    By Samson in forum Windows
    Replies: 3
    Last Post: 12th March 2007, 09:15 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •