View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Importing from SQL as a Number instead of Text

You can use this simple macro to find the cells that are text. Cahnge the
range A1:D10 as required.


Sub findtext()

Set SearchRange = Range("A1:D10")

For Each cell In SearchRange
If Not IsNumeric(cell) Then
MsgBox ("Cell : " & cell.Address & " is Text")
End If
Next cell
End Sub

"Jez" wrote:

All the Cells are already set to General, The Field I take them from in SQL
Server is an INT.
Clicking on the cell shows no single quote or space in front of the number

I dont know where to go from here

"Joel" wrote:

I can't tell what the problem is without seeing the SQL statements. The data
may be stored in the database (or website) in text format, th eSQL statements
may be converting the numbers to text, or the spreadsheet may be formated as
text.

Here are some thngs to check

1) Click on a cell and see if there is a single quote infront of the number
or a space in front of the number.
2) click on the cell and then check the format by going to menu Format -
Cels - Number ans seeing which format is highlighted. If the format is TEXT
change format to number or general.

"Jez" wrote:

I have code that imports a query from SQL Server and pastes the results into
certain cells. This works great, my problem is that when I come to find the
Max number from a range of cells, they all seem to be as Text...

How can when importing them change them from Text to Number?