[FONT="]I have this code (below) that works for worksheet "CHIT". I want to modify this code so that it works for another worksheet "CHIT2".[/FONT]
[FONT="]So if I double click on worksheet "CHIT", it also works on worksheet "CHIT2".[/FONT]
[FONT="]Any help is appreciated[/FONT]
[FONT="]CODE:[/FONT]
[FONT="]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)[/FONT]
[FONT="]
[/FONT]
[FONT="]Dim c As Range, a[/FONT]
[FONT="] If Target.Address = "$K$8" Then[/FONT]
[FONT="] ' Don't edit the cell[/FONT]
[FONT="] Cancel = True[/FONT]
[FONT="] ' Increment the invoice nunber[/FONT]
[FONT="] Set c = Worksheets("CHIT").Range("J8")[/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 If[/FONT]
[FONT="]
[/FONT]
[FONT="]End Sub[/FONT]
[FONT="]So if I double click on worksheet "CHIT", it also works on worksheet "CHIT2".[/FONT]
[FONT="]Any help is appreciated[/FONT]
[FONT="]CODE:[/FONT]
[FONT="]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)[/FONT]
[FONT="]
[/FONT]
[FONT="]Dim c As Range, a[/FONT]
[FONT="] If Target.Address = "$K$8" Then[/FONT]
[FONT="] ' Don't edit the cell[/FONT]
[FONT="] Cancel = True[/FONT]
[FONT="] ' Increment the invoice nunber[/FONT]
[FONT="] Set c = Worksheets("CHIT").Range("J8")[/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 If[/FONT]
[FONT="]
[/FONT]
[FONT="]End Sub[/FONT]