C
cham.behrooz
I am using following vba code from mcgimpsey website on my
Thisworkbook and it works fine but I like to know how to apply the
same code to Sheet 2 and 3 on my workbook. Basically I want the result
in cell B2 would show up on the same cell of Sheet 2 and 3. Anybody
can help?
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long
With ThisWorkbook.Sheets("Sheet1")
With .Range("B1")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("B2")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber
+ 1&
End If
End With
End With
End Sub
Thisworkbook and it works fine but I like to know how to apply the
same code to Sheet 2 and 3 on my workbook. Basically I want the result
in cell B2 would show up on the same cell of Sheet 2 and 3. Anybody
can help?
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long
With ThisWorkbook.Sheets("Sheet1")
With .Range("B1")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("B2")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber
+ 1&
End If
End With
End With
End Sub