Hi,
I have these codes in Workbook
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ws As Worksheet
Set ws = Worksheets("CHIT")
If Sh.Name = ws.Name Then
ws.Range("C12") = Application.UserName
End If
Set ws = Nothing
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("CHIT").Range("J9,J12,C14,E28,E29").Interior.ColorIndex = 6
End Sub
Now I added this code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim c As Range, a
Set c = Worksheets("Chit").Range("J8")
c.NumberFormat = "@"
If InStr(c, "/") = 0 Then
c = "000001/" & Format(Date, "yy")
Else
a = Split(c, "/")
a(0) = Format(a(0) + 1, "00000#")
If Format(a(1), "00") <> Format(Date, "yy") Then a(1) = Format(Date, "yy")
c = Join(a, "/")
End If
End Sub
When I added the code above, it gave me this error:
Compile error:
Ambiguous name detected: Workbook_BeforeSave
and the line below became highlighted.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean
Will someone help me to fix this.
Thanks in advance
I have these codes in Workbook
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ws As Worksheet
Set ws = Worksheets("CHIT")
If Sh.Name = ws.Name Then
ws.Range("C12") = Application.UserName
End If
Set ws = Nothing
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("CHIT").Range("J9,J12,C14,E28,E29").Interior.ColorIndex = 6
End Sub
Now I added this code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim c As Range, a
Set c = Worksheets("Chit").Range("J8")
c.NumberFormat = "@"
If InStr(c, "/") = 0 Then
c = "000001/" & Format(Date, "yy")
Else
a = Split(c, "/")
a(0) = Format(a(0) + 1, "00000#")
If Format(a(1), "00") <> Format(Date, "yy") Then a(1) = Format(Date, "yy")
c = Join(a, "/")
End If
End Sub
When I added the code above, it gave me this error:
Compile error:
Ambiguous name detected: Workbook_BeforeSave
and the line below became highlighted.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean
Will someone help me to fix this.
Thanks in advance