ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatting issue (https://www.excelbanter.com/excel-programming/386955-formatting-issue.html)

[email protected]

Formatting issue
 
I have a simple worksheet that populates the sheet with numbers based
on 3 variables from a second sheet. Everything is working correctly up
until I add a couple of text characters to each entry: "in", it is the
last process that needs to be done to the numbers - unfortunately
doing this kills the number formatting.

An example of the number entries before the "in" is added at the end:

-0.00615808

After adding the "in":

-6.15808000000001E-03in

Below is part of the routine I am using (it's rough so don't mind the
basic format):

Do
i = i + 1
Sheets(sn).Cells(i, 2).Select
Selection.Value = Sheets("Parameters").Cells(i - 1,
2).Value - Sheets("Variables").Cells(2, 3).Value
Selection.NumberFormat = "0.00000000"
Loop Until Sheets("Parameters").Cells(i, 1).Value = a

i = 0
Do
i = i + 1
Sheets(sn).Cells(i, 1).Select
Selection.Value = Selection.Value & "in"
Sheets(sn).Cells(i, 2).Select
Selection.Value = Selection.Value & "in"
Loop Until Sheets("Parameters").Cells(i, 1).Value = a & "in"

Any help is appreciated.

Chad


Peter T

Formatting issue
 
Hi Chad,

When you add the "in" the cell contains text, so the numberformat is not
applied. For cells you want the "in" suffix try -

..NumberFormat = "0.00000000""in"""

and don't add the ' & "in" ' to your values

In passing, try and amend your code to remove all those Select/Selection's,
none are necessary.

Regards,
Peter T

wrote in message
ps.com...
I have a simple worksheet that populates the sheet with numbers based
on 3 variables from a second sheet. Everything is working correctly up
until I add a couple of text characters to each entry: "in", it is the
last process that needs to be done to the numbers - unfortunately
doing this kills the number formatting.

An example of the number entries before the "in" is added at the end:

-0.00615808

After adding the "in":

-6.15808000000001E-03in

Below is part of the routine I am using (it's rough so don't mind the
basic format):

Do
i = i + 1
Sheets(sn).Cells(i, 2).Select
Selection.Value = Sheets("Parameters").Cells(i - 1,
2).Value - Sheets("Variables").Cells(2, 3).Value
Selection.NumberFormat = "0.00000000"
Loop Until Sheets("Parameters").Cells(i, 1).Value = a

i = 0
Do
i = i + 1
Sheets(sn).Cells(i, 1).Select
Selection.Value = Selection.Value & "in"
Sheets(sn).Cells(i, 2).Select
Selection.Value = Selection.Value & "in"
Loop Until Sheets("Parameters").Cells(i, 1).Value = a & "in"

Any help is appreciated.

Chad




[email protected]

Formatting issue
 
On Apr 5, 7:29 pm, "Peter T" <peter_t@discussions wrote:
Hi Chad,

When you add the "in" the cell contains text, so the numberformat is not
applied. For cells you want the "in" suffix try -

.NumberFormat = "0.00000000""in"""

and don't add the ' & "in" ' to your values

In passing, try and amend your code to remove all those Select/Selection's,
none are necessary.

Regards,
Peter T

wrote in message

ps.com...

I have a simple worksheet that populates the sheet with numbers based
on 3 variables from a second sheet. Everything is working correctly up
until I add a couple of text characters to each entry: "in", it is the
last process that needs to be done to the numbers - unfortunately
doing this kills the number formatting.


An example of the number entries before the "in" is added at the end:


-0.00615808


After adding the "in":


-6.15808000000001E-03in


Below is part of the routine I am using (it's rough so don't mind the
basic format):


Do
i = i + 1
Sheets(sn).Cells(i, 2).Select
Selection.Value = Sheets("Parameters").Cells(i - 1,
2).Value - Sheets("Variables").Cells(2, 3).Value
Selection.NumberFormat = "0.00000000"
Loop Until Sheets("Parameters").Cells(i, 1).Value = a


i = 0
Do
i = i + 1
Sheets(sn).Cells(i, 1).Select
Selection.Value = Selection.Value & "in"
Sheets(sn).Cells(i, 2).Select
Selection.Value = Selection.Value & "in"
Loop Until Sheets("Parameters").Cells(i, 1).Value = a & "in"


Any help is appreciated.


Chad


Thanks, works very well.



All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com