View Single Post
Old 01-02-2015, 05:00 AM
george_m george_m is offline
Join Date: Mar 2012
Posts: 20

I've also noticed when running VB program that everything in BeforeSave event in Excel file is done on the last edited sheet (sheet number 2) and not on the sheet that should be created (sheet number 3). This is code from VBA:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

If Cells(1, 1).Value = 0 Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "3"
ActiveSheet.Cells(1, 1).Value = 10
End If

End Sub
Value 10 appears on the second sheet not on the new one (third). I'm missing something in declaring in VB code...
Reply With Quote