Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everone,
I have this line of VBA code: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 7)) One of the values that it writes down comes like this: 3.84894 while when I checked it using MsgBox, it came as this: 3.84894E-02 What should I do to let the code write it correctly as: .0384894? Regards, Mike |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
? 3.84894E-02
0.0384894 What are you trying to accomplish with the code that you show? -- Regards, Tom Ogilvy "Michael" wrote in message om... Hi everone, I have this line of VBA code: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 7)) One of the values that it writes down comes like this: 3.84894 while when I checked it using MsgBox, it came as this: 3.84894E-02 What should I do to let the code write it correctly as: .0384894? Regards, Mike |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am running an optimization model. Upon finding a solution, the VBA
code will write down the solution values into an excel sheet. Some of the values come from the optimization model, upon finding a solution, like 3.84894E-02 for example. However, it writes down in excel sheet as 3.8489 So, the line I am using: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline,Aline).Value, 7)) needs some fixing I think so the number can be written as .08489 for example. Regards, Mike "Tom Ogilvy" wrote in message ... ? 3.84894E-02 0.0384894 What are you trying to accomplish with the code that you show? -- Regards, Tom Ogilvy "Michael" wrote in message om... Hi everone, I have this line of VBA code: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 7)) One of the values that it writes down comes like this: 3.84894 while when I checked it using MsgBox, it came as this: 3.84894E-02 What should I do to let the code write it correctly as: .0384894? Regards, Mike |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if you place 3.84894E-02 in a cell and then format it with
format=Cells=Number tab and select 7 decimals, it should appear as you want it. -- Regards, Tom Ogilvy "Michael" wrote in message m... I am running an optimization model. Upon finding a solution, the VBA code will write down the solution values into an excel sheet. Some of the values come from the optimization model, upon finding a solution, like 3.84894E-02 for example. However, it writes down in excel sheet as 3.8489 So, the line I am using: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline,Aline).Value, 7)) needs some fixing I think so the number can be written as .08489 for example. Regards, Mike "Tom Ogilvy" wrote in message ... ? 3.84894E-02 0.0384894 What are you trying to accomplish with the code that you show? -- Regards, Tom Ogilvy "Michael" wrote in message om... Hi everone, I have this line of VBA code: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 7)) One of the values that it writes down comes like this: 3.84894 while when I checked it using MsgBox, it came as this: 3.84894E-02 What should I do to let the code write it correctly as: .0384894? Regards, Mike |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
What you are saying is true. However, it is not exactly what I have! May be I did put it right. Let me re-word it please. When I put the following VBA line: MsgBox ARngSolution(Cline, Aline).Value I see that value, say: 3.84894E-02 When I look in the excel sheet where the value is written, I see it 3.84894 It is like the "E-02" is completely missed!? What am I doing wrong? Should I change this VBA line: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 5)) Thanks, Mike "Tom Ogilvy" wrote in message ... if you place 3.84894E-02 in a cell and then format it with format=Cells=Number tab and select 7 decimals, it should appear as you want it. -- Regards, Tom Ogilvy "Michael" wrote in message m... I am running an optimization model. Upon finding a solution, the VBA code will write down the solution values into an excel sheet. Some of the values come from the optimization model, upon finding a solution, like 3.84894E-02 for example. However, it writes down in excel sheet as 3.8489 So, the line I am using: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline,Aline).Value, 7)) needs some fixing I think so the number can be written as .08489 for example. Regards, Mike "Tom Ogilvy" wrote in message ... ? 3.84894E-02 0.0384894 What are you trying to accomplish with the code that you show? -- Regards, Tom Ogilvy "Michael" wrote in message om... Hi everone, I have this line of VBA code: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 7)) One of the values that it writes down comes like this: 3.84894 while when I checked it using MsgBox, it came as this: 3.84894E-02 What should I do to let the code write it correctly as: .0384894? Regards, Mike |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could use Tom's formatting suggestion in code like:
ARngSolution(Cline, Aline).numberformat = "0.0000000" or in the msgbox: msgbox format(ARngSolution(Cline, Aline).value,"0.0000000") (count those decimal places--just in case I counted wrong.) Michael wrote: Tom, What you are saying is true. However, it is not exactly what I have! May be I did put it right. Let me re-word it please. When I put the following VBA line: MsgBox ARngSolution(Cline, Aline).Value I see that value, say: 3.84894E-02 When I look in the excel sheet where the value is written, I see it 3.84894 It is like the "E-02" is completely missed!? What am I doing wrong? Should I change this VBA line: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 5)) Thanks, Mike "Tom Ogilvy" wrote in message ... if you place 3.84894E-02 in a cell and then format it with format=Cells=Number tab and select 7 decimals, it should appear as you want it. -- Regards, Tom Ogilvy "Michael" wrote in message m... I am running an optimization model. Upon finding a solution, the VBA code will write down the solution values into an excel sheet. Some of the values come from the optimization model, upon finding a solution, like 3.84894E-02 for example. However, it writes down in excel sheet as 3.8489 So, the line I am using: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline,Aline).Value, 7)) needs some fixing I think so the number can be written as .08489 for example. Regards, Mike "Tom Ogilvy" wrote in message ... ? 3.84894E-02 0.0384894 What are you trying to accomplish with the code that you show? -- Regards, Tom Ogilvy "Michael" wrote in message om... Hi everone, I have this line of VBA code: ARngSolution(Cline, Aline).Value = Val(Left(ARngSolution(Cline, Aline).Value, 7)) One of the values that it writes down comes like this: 3.84894 while when I checked it using MsgBox, it came as this: 3.84894E-02 What should I do to let the code write it correctly as: .0384894? Regards, Mike -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
not printing correctly | Excel Discussion (Misc queries) | |||
How to correctly write a cross-sheet "IF" formula in Excel | Excel Worksheet Functions | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions | |||
How do I use checkboxes correctly? | Excel Discussion (Misc queries) | |||
I hope I ask this correctly | Excel Programming |