Macro/keyboard shortcut to increment a cell value

T

Top Spin

I would like to set up a keyboard shortcut (e.g., Ctrl+I) that would
increment the value of the selected cell by 1.

Can someone get me started by pointing me in the right direction? I
have some experience creating simple macros in Word, if that is what's
needed.

Thanks

--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 
D

Dave Peterson

One way is to make a macro and assign the shortcut key to it:

Option Explicit
Sub AddOneToActiveCell()
With ActiveCell
If IsNumeric(.Value) Then
.Value = .Value + 1
End If
End With
End Sub

Tools|macro|macros
select AddOneToActiveCell
Options
Assign your shortcut key.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
T

Top Spin

One way is to make a macro and assign the shortcut key to it:

Option Explicit
Sub AddOneToActiveCell()
With ActiveCell
If IsNumeric(.Value) Then
.Value = .Value + 1
End If
End With
End Sub

Excellent. That works like a charm.

Thanks
Tools|macro|macros
select AddOneToActiveCell
Options
Assign your shortcut key.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 
T

Top Spin

One way is to make a macro and assign the shortcut key to it:

Option Explicit
Sub AddOneToActiveCell()
With ActiveCell
If IsNumeric(.Value) Then
.Value = .Value + 1
End If
End With
End Sub

Tools|macro|macros
select AddOneToActiveCell
Options
Assign your shortcut key.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

One little problem. The macro ran just fine when I first created it.
But after I closed Excel and reopened it later, I get this message:

"The macros in this project are disabled."

After reading a bit in the archives, it appears that Excel has a
different security system than does Word. I have written a number of
Word macros and never had a security problem.

Is there some easy way to get around the problem? I think I should
probably leave the security setting on high but I would like my own
macros to be automatically exempt.

How come it allowed them when I first created them? Is there some way
to flag them with that flag forever?

Thanks

--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 
G

Gord Dibben

Tools>Options>Security>Macro Security.

Set to "medium". You will get a warning, but your macros will run when you
click on "enable".

If just for your own personal use you can create a digital certificate using
the "self cert" application that comes with Office.

Look for selfcert.exe and run it to create a certificate.

When added to the Trusted Sources, this by-passes the warning when that
workbook starts.

For help on certificates go to Answer Wizard and "certificates"

Note: you must go into the VBE and Tools>Digital Certificate and select your
certificate.

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top