Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Converting a "Stringed" Number to a Number

  Asked By: Dukker    Date: Jan 16    Category: MS Office    Views: 1140
  

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. ?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Mildred Bailey     Answered On: Jan 16

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

 
Answer #2    Answered By: Lee Butler     Answered On: Jan 16


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.).

 
Answer #3    Answered By: Jennifer Davis     Answered On: Jan 16

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.




Tagged: