![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 217
|
Hi,
I have just come across a problem. I extracted from a database fields which have numbers in it but when they are received in Excel they are actually text. Now I am faced with the problem of converting them to a number field. I wanted to use the vlookup function and wanted to compare two numbers but because one is a text field and the other a number it returns #N/A. Thanks for your help Andonny |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Try, Code:
Sub tester()
Dim Cell As Range, Rng1 As Range
Set Rng1 = Intersect(ActiveSheet.UsedRange, ActiveSheet.Range("A:A"))
For Each Cell In Rng1
If Not IsEmpty(Cell) And Not Cell.HasFormula And IsNumeric(Cell) Then
Cell = CDbl(Cell)
End If
Next Cell
End Sub
Adjust your range to suit. Bye, Jay |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Select your values, choose the Data | Text to Columns... menu command and press [ Finish ].
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|