Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default How to write this correctly?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to write this correctly?

? 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default How to write this correctly?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to write this correctly?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default How to write this correctly?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How to write this correctly?

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
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
not printing correctly QB Excel Discussion (Misc queries) 0 November 3rd 09 09:49 PM
How to correctly write a cross-sheet "IF" formula in Excel Jay Excel Worksheet Functions 4 November 17th 05 01:20 AM
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? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
How do I use checkboxes correctly? erikeve Excel Discussion (Misc queries) 1 January 15th 05 06:31 PM
I hope I ask this correctly Mark Excel Programming 3 March 5th 04 03:23 PM


All times are GMT +1. The time now is 04:21 AM.

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"