ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   1000 to 1 and 1 to 1000 (https://www.excelbanter.com/excel-worksheet-functions/113140-1000-1-1-1000-a.html)

Olle

1000 to 1 and 1 to 1000
 
When I type 1000 in one cell and then push enter, I would like that only 1 is
shown.

Vice versa, typing 1 €“ I would like the cell to show 1000.



CLR

1000 to 1 and 1 to 1000
 
This Change-event code might be what you're looking for.....

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target = 1 Then
Target.Value = 1000
Else
If Target = 1000 Then
Target.Value = 1
Else
End If
End If
End Sub

Vaya con Dios,
Chuck, CABGx3



"Olle" wrote:

When I type 1000 in one cell and then push enter, I would like that only 1 is
shown.

Vice versa, typing 1 €“ I would like the cell to show 1000.



David Biddulph

1000 to 1 and 1 to 1000
 
"Olle" wrote in message
...
When I type 1000 in one cell and then push enter, I would like that only 1
is
shown.

Vice versa, typing 1 - I would like the cell to show 1000.


You could use Tools/ AutoCorrect Options, but it sounds a dangerous way of
asking your sheet to behave.
--
David Biddulph




vezerid

1000 to 1 and 1 to 1000
 
Chuck,
you speak of the Change event but you are giving a SelectionChange
routine. With this one 1 and 1000 will be toggled whenever one clicks
on a cell containing either value.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = 1 Or Target.Value = 1000 Then
Application.EnableEvents = False
If Target.Value = 1 Then
Target.Value = 1000
Else
Target.Value = 1
End If
Application.EnableEvents = True
End If
End Sub

HTH
Kostis Vezerides


Olle

1000 to 1 and 1 to 1000
 
I found the answer my self:

Tools €“ options €“ Edit and look for fixed decimal places.

Thanks anyhow // Olle


"Olle" wrote:

When I type 1000 in one cell and then push enter, I would like that only 1 is
shown.

Vice versa, typing 1 €“ I would like the cell to show 1000.



David Biddulph

1000 to 1 and 1 to 1000
 
Yes, but that would only work in one direction or the other, but not both.
--
David Biddulph

"Olle" wrote in message
...
I found the answer my self:

Tools - options - Edit and look for fixed decimal places.

Thanks anyhow // Olle


"Olle" wrote:

When I type 1000 in one cell and then push enter, I would like that only
1 is
shown.

Vice versa, typing 1 - I would like the cell to show 1000.





All times are GMT +1. The time now is 09:54 AM.

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