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
- Converting a number to a sentence
- 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
- Count the number of rows on a worksheet, divide the count by 15
- Count unique names in listbox & put the number on the userform
- Detecting text vs numbers with an If/Then
- VBA to use unique password using volume serial number
- How to control number of textboxes according to user input
- IP numbers
- Read hardware serial number and execute OS Commands?
- How do I validate Phone numbers in java/ email addresses
- large numbers in java
- find the number of working days (monday to firday) between two give
- Formatting a Number
- Problem with random number in java
- How to truncate a floating number?
- Pocket PC 2002 PDA to dail a phone number
- Number Format
- generating random numbers
- Getting CPU Number (Id) of a computer using Applet
- Formatting number