code to increment a cell!

  • Thread starter Thread starter David#
  • Start date Start date
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
 
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
 
Back
Top