Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an array that contains string values. When I put one of these values
into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim DataRow as string
Dim DataRow(12) as string "DG" wrote: I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Seems slightly strange your string is being coerced to a number in a cell
that you say is already formatted as text. What happens if you run this - s$ = Format(Now, "yyyymmddhhmmss") With ActiveCell ..NumberFormat = "@" ..Value = s End With Regards, Peter T "DG" wrote in message ... I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Joel but that did not work.
I even tried Sheets("Sheet2").Cells(Line,9) = Str(DataRow(9)) but got a type mismatch error Any other ideas? DG "Joel" wrote in message ... Dim DataRow as string Dim DataRow(12) as string "DG" wrote: I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Peter,
I ran your script and it put 20080418100810 in cell A1 with the warning that I have a number foratted as text in the cell. DG "Peter T" <peter_t@discussions wrote in message ... Seems slightly strange your string is being coerced to a number in a cell that you say is already formatted as text. What happens if you run this - s$ = Format(Now, "yyyymmddhhmmss") With ActiveCell .NumberFormat = "@" .Value = s End With Regards, Peter T "DG" wrote in message ... I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK, so what happens if you format your cells the same way before you dump
your string values to the cells. Regards, Peter T "DG" wrote in message ... Hi Peter, I ran your script and it put 20080418100810 in cell A1 with the warning that I have a number foratted as text in the cell. DG "Peter T" <peter_t@discussions wrote in message ... Seems slightly strange your string is being coerced to a number in a cell that you say is already formatted as text. What happens if you run this - s$ = Format(Now, "yyyymmddhhmmss") With ActiveCell .NumberFormat = "@" .Value = s End With Regards, Peter T "DG" wrote in message ... I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found it.
I was manually formating the column to text BEFORE I ran the macro. At the begining of the macro I have: With Range("A8:K10000") .Clear End With which removed the format. When I comment this out my macro works. Problem is that I need that clear. So Can you tell me how to format column I as text? DG "DG" wrote in message ... Hi Peter, I ran your script and it put 20080418100810 in cell A1 with the warning that I have a number foratted as text in the cell. DG "Peter T" <peter_t@discussions wrote in message ... Seems slightly strange your string is being coerced to a number in a cell that you say is already formatted as text. What happens if you run this - s$ = Format(Now, "yyyymmddhhmmss") With ActiveCell .NumberFormat = "@" .Value = s End With Regards, Peter T "DG" wrote in message ... I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Got it.
..NumberFormat = "@" Thanks "DG" wrote in message ... I found it. I was manually formating the column to text BEFORE I ran the macro. At the begining of the macro I have: With Range("A8:K10000") .Clear End With which removed the format. When I comment this out my macro works. Problem is that I need that clear. So Can you tell me how to format column I as text? DG "DG" wrote in message ... Hi Peter, I ran your script and it put 20080418100810 in cell A1 with the warning that I have a number foratted as text in the cell. DG "Peter T" <peter_t@discussions wrote in message ... Seems slightly strange your string is being coerced to a number in a cell that you say is already formatted as text. What happens if you run this - s$ = Format(Now, "yyyymmddhhmmss") With ActiveCell .NumberFormat = "@" .Value = s End With Regards, Peter T "DG" wrote in message ... I have an array that contains string values. When I put one of these values into my spreadsheet it changes to Scientific. Dim DataRow(12) DataRow(9)="201E-13" ' for this example Line = 2 ' for this example Sheets("Sheet2").Cells(Line,9) = DataRow(9) The result in Sheet2 I2 = 2.01E-11 and the format is Scientific. I manually set this column to text before running the macro. Any help would be great. DG |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formating problem | Excel Programming | |||
Formating Problem | Excel Discussion (Misc queries) | |||
formating problem, PLEASE help. | Excel Discussion (Misc queries) | |||
VBA Conditional Formating Problem | Excel Programming | |||
Date formating problem | Excel Programming |