code to increment a cell!

D

David#

Can code a cell or an adjacent cell so that it will
increase in value (by 1) each time it is selected or
tabbed through (i.e. if it shows "61" I need to select
it or tab thru it, then have it show "62")

Thanks for your help!! David
 
B

Bernie Deitrick

David,

You can use the Worksheet_SelectionChange event:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then Target.Value = Target.Value + 1
End Sub

Right Click on the sheet tab, select "View Code" and paste this code in the module that appears.

HTH,
Bernie
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