ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Cell Format subtracting 1 (https://www.excelbanter.com/excel-discussion-misc-queries/129517-cell-format-subtracting-1-a.html)

Wendy

Cell Format subtracting 1
 
I would like to format a cell that each time a number is typed in it will
subtract 1 from that number. I do not want to put a formula in another colum
to do this, just when I type in a 5 for example the 5 would change to a 4.
Can this be done?

Teethless mama

Cell Format subtracting 1
 
Simple, put 1 less of the actual number


"Wendy" wrote:

I would like to format a cell that each time a number is typed in it will
subtract 1 from that number. I do not want to put a formula in another colum
to do this, just when I type in a 5 for example the 5 would change to a 4.
Can this be done?


Bob Phillips

Cell Format subtracting 1
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If IsNumeric(.Value) Then .Value = .Value - 1
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Wendy" wrote in message
...
I would like to format a cell that each time a number is typed in it will
subtract 1 from that number. I do not want to put a formula in another
colum
to do this, just when I type in a 5 for example the 5 would change to a 4.
Can this be done?




Bob Phillips

Cell Format subtracting 1
 
LOL! think of a number, and subtract 1.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Teethless mama" wrote in message
...
Simple, put 1 less of the actual number


"Wendy" wrote:

I would like to format a cell that each time a number is typed in it will
subtract 1 from that number. I do not want to put a formula in another
colum
to do this, just when I type in a 5 for example the 5 would change to a
4.
Can this be done?




Gord Dibben

Cell Format subtracting 1
 
Wendy

How about a Spinner from the Forms toolbar.

Then you could go down or up as you choose.


Gord Dibben MS Excel MVP

On Tue, 6 Feb 2007 14:57:00 -0800, Wendy
wrote:

I would like to format a cell that each time a number is typed in it will
subtract 1 from that number. I do not want to put a formula in another colum
to do this, just when I type in a 5 for example the 5 would change to a 4.
Can this be done?




All times are GMT +1. The time now is 09:53 PM.

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