Search: | |||||

| ||||

Home » Forum » MS Office | RSS Feeds |

How can I convert a "Stringed" number to a number eg. strNumber

= "234". How do I now get vNumber to equal the number value of

strNumber ie 234. ?

There are two methods.

1) You could highlight the row in question, and click on the

exclamation mark of the first numbered cell. Assuming you have Office

20003. A list of options will appear allowing you to convert numbers

stored as text to number.

2) The other is to write a loop statement

The following example will start at the selected cell on the

spreadsheet.

Dim lRange As Long

Dim l As Long

Dim iNum As Integer

lRange = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row

For l = 1 To lRange

iNum = Val(ActiveCell.Value)

ActiveCell.Value = iNum

ActiveCell.Offset(1, 0).Select

Next

Use

vNumber = Val(strNumber)

Or

vNumber = CInt(strNumber)

Val() and CInt() have slightly different functionality for unusual

conditions.

For example, CInt(“234a”) returns an error, while Val(“234a”) returns 234.

It’s up to you which one is more appropriate in your application.

There’s also CLng() to convert to a Long (and CBool() to convert to Boolean,

CSng() to convert to Single, CDbl() to convert to Double, CStr() to convert

to String, CDate() to convert to Date, etc.).

Depends where it is. If it is on the spreadsheet I usually put the value 1 in

a cell, copy it, and then Paste Special (values multiply).

In other word if you multiply "1234" by 1 you get 1234.

Didn't find what you were looking for?
Find more on Converting a "Stringed" Number to a Number
Or get search suggestion and latest updates.

Related Topics:

- Converting a "Stringed" Number to a Number
- convert from number (0-255) to character
- problem of converting a number into words using double
- converting numbers into words using double
- Converting numbers to words
- Convert Serial Number to a Date Function
- Converting a number to a sentence
- Number fields in Excel being considered NULL (empty)
- Math function to determine if a number is an int
- Getting the time for the Number of records retrived
- Datagrid Display - right align numbers
- Error preallocating sequence numbers. The sequence table information
- How to access the Phone Number from the J2ME Application
- get the number of JList which is created by array
- changing the port number on JBOSS
- julian day number
- Formating the Number
- Jbuilder Serial number
- Pocket PC 2002 PDA to dail a phone number
- generating random numbers
- Number Format
- Fibonacci and Prime numbers
- How to truncate a floating number?
- Getting CPU Number (Id) of a computer using Applet
- Formatting number