[FONT="]Hello,[/FONT]
[FONT="]I have a code that runs with a Command button. Is it possible to modify the code so that it runs when I click a particular cell?[/FONT]
[FONT="]This is my code:[/FONT]
[FONT="]Private Sub CommandButton1_Click()[/FONT]
[FONT="]Dim c As Range, a[/FONT]
[FONT="] Set c = Worksheets("Sheet1").Range("A1")[/FONT]
[FONT="] c.NumberFormat = "@"[/FONT]
[FONT="] If InStr(c, "/") = 0 Then[/FONT]
[FONT="] c = "000001/" & Format(Date, "yy")[/FONT]
[FONT="] Else[/FONT]
[FONT="] a = Split(c, "/")[/FONT]
[FONT="] a(0) = Format(a(0) + 1, "00000#")[/FONT]
[FONT="] If Format(a(1), "00") <> Format(Date, "yy") Then a(1) = Format(Date, "yy")[/FONT]
[FONT="] c = Join(a, "/")[/FONT]
[FONT="] End If[/FONT]
[FONT="]End Sub[/FONT]
[FONT="]Thanks in advance[/FONT]
[FONT="]I have a code that runs with a Command button. Is it possible to modify the code so that it runs when I click a particular cell?[/FONT]
[FONT="]This is my code:[/FONT]
[FONT="]Private Sub CommandButton1_Click()[/FONT]
[FONT="]Dim c As Range, a[/FONT]
[FONT="] Set c = Worksheets("Sheet1").Range("A1")[/FONT]
[FONT="] c.NumberFormat = "@"[/FONT]
[FONT="] If InStr(c, "/") = 0 Then[/FONT]
[FONT="] c = "000001/" & Format(Date, "yy")[/FONT]
[FONT="] Else[/FONT]
[FONT="] a = Split(c, "/")[/FONT]
[FONT="] a(0) = Format(a(0) + 1, "00000#")[/FONT]
[FONT="] If Format(a(1), "00") <> Format(Date, "yy") Then a(1) = Format(Date, "yy")[/FONT]
[FONT="] c = Join(a, "/")[/FONT]
[FONT="] End If[/FONT]
[FONT="]End Sub[/FONT]
[FONT="]Thanks in advance[/FONT]