Increasing easily the number in a cell.

  • Thread starter Thread starter DB.
  • Start date Start date
D

DB.

I have a very large number (8 digits, perhaps) in a cell and wish to
increase marginally that number (add 2, say) without re-typing (almost)
the entire string of digits. Is there an easy way (maybe holding down a
simple key-combination then hitting "2") that will achieve my aim?

TIA of any reply.
 
Hi,
A simple macro will do this for you.
The following would be the simplest.

Sub Increment()
Range("A1").Value = Range("A1").Value + 1
End Sub

Assign a button or a short-cut key to the macro. Each time it runs, your
number will increase by 1.
I've assumed your number is in cell A1. Change the reference as necessary.

Regards - Dave.
 
Thanks for your quick reply, Don.
But holding down the f2 key and hitting "2" appends a 2 to the end
of the number (so that 15016283 becomes 150162832) whereas I want to
increase the number itself by 2 - i.e. for it to become 15016285.
Is there a simple way to do this, please? (And, similarly, a simple
way to subtract that 2 from my original number?).
Thanks again,
 
Right click sheet tab>view code>insert this>change f1 to your cell address.
Now when you right click on the cell the number will be increased by 2

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Target, Range("f1")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = Target + 2
Application.EnableEvents = True
End Sub
 
Thanks again, Don. But that solution is rather more complex than
I'd hoped for - this old dog is finding it increasingly difficult to
learn new tricks!
It's getting late here in UK - I must leave it until tomorrow to see
if I can fathom the meaning of your reply.

BW's,
(another) Don
 
Hi DB,

It depends on your actual needs and exactly what sort of functionality
you require. Here are a couple of non macro ways of incrementing cells.

1) Put 2 in an empty cell and copy it.
Then right click on your target cell.
Select Paste Special.
Check Add
And OK out.
(This way works well if you have a lot of cells to add 2 to)

2) Go to View>Toolbars>Forms.
On the Forms toolbar select a Spinner (small box with an Up arrow
and a Down arrow)
Left click and drag a box to set your spinner button.
Right click on the button and select format control.
In the dialag box set the incremental change you want
and set the cell link to a blank cell and OK out.
Click on the arrows a few times to see how it works.

Depending on your requirements, you can apply the spinner
directly to your target cell or you can put it in another cell
and reference it with a formula.
As an example if you were to
put =A2/10 in cell A1
put a spinner in A2
Succeessive clicks of the spinner will increase A1
in 0.1 increments
The spinner won't go negative so you have to adjust
the starting point to get that effect.

HTH
Martin
 
Back
Top