Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: Convert Text to number in vba

Status
Not open for further replies.

robdunfey

Technical User
Apr 26, 2002
110
GB
Hi,

I import numbers from access into excel, but they are regarded as text in excel(aligned to left of cell). how can i programatically convert this text to numbers?

Any help much appreciated.

Rob
 
Hi Rob
There may be some way of doing what you're looking for during the import process but I'm not too sure about things like that!

In the meantime the following will give an example of changing the format once into Excel. Note only use one of the options!

With Range("A1:A15")
'use one of these as an example
.NumberFormat = "General"
.NumberFormat = "#,##0.000"
End With

;-)
 
Try
Code:
    Dim oCell As Range
    For Each oCell In Selection
        oCell = Val(oCell)
    Next
This works with the current selection. You can replace Selection with the address of a spcified range if that suits, e.g. For Each oCell In Range("A1:C100")

A.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top