Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jez Jez is offline
external usenet poster
 
Posts: 38
Default Importing from SQL as a Number instead of Text

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Importing from SQL as a Number instead of Text

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jez Jez is offline
external usenet poster
 
Posts: 38
Default Importing from SQL as a Number instead of Text

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?

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

A easy way to really determine if a cell is Text or a number is to use the
formula
=Sum(A1)

If the formula returns zero then the cell A1 is Text, otherwise it will
return the number in A1. You can change th eformula to any cell or range of
cells like
=Sum(A1:A5) or you can use =Max(A1:A5)

One possibility is there is a problem with only some of the cells and not
all the cells. Experiment a try to isolate the problem by changing the range
of the cells in the formula(s) until you find which ones are problems.



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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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?



  #6   Report Post  
Posted to microsoft.public.excel.programming
Jez Jez is offline
external usenet poster
 
Posts: 38
Default Importing from SQL as a Number instead of Text

Thanks I tried that code over the whole range of data and spent time looking
at each cell. All cells I was looking to be as a number were and all the text
fields were text fields, so I dont understand why this doesnt work...

=MAX(C12,F12,I12,C24,F24)

"Joel" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Changes Text Cells to Number Cells When Importing XML Villerat Excel Discussion (Misc queries) 0 July 24th 08 01:59 AM
Importing text--cell text limit? Scout Excel Discussion (Misc queries) 1 July 2nd 08 08:38 PM
Importing DBF with large number of fields [email protected] Excel Programming 0 December 11th 07 03:35 PM
Importing CSV file (saved as Text) into XL as Text -- over 60 colu sbp Excel Discussion (Misc queries) 1 October 14th 06 11:50 PM
Importing a Large Number of Columns jmpreiks Excel Discussion (Misc queries) 0 March 19th 06 11:42 PM


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"