Hi All,
I'm sure this is really simple but I just can't figure out what's wrong
I have a small piece of code in the 'ThisWorkbook' module that changes a specific cell from FALSE/TRUE whenever the workbook is saved
Unfortunately this code executes on whichever sheet I am on at the time![]()
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Range("N149").Select ActiveCell.FormulaR1C1 = "FALSE" End Sub ---------------------------------------------------------------------------- Private Sub Workbook_AfterSave(ByVal Success As Boolean) Range("N149").Select ActiveCell.FormulaR1C1 = "TRUE" End Sub
How can I specify which sheet this should run on?
I've tried the following
But this gives "Runtime error 1004 - select method of range class failed"![]()
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Sheets("INV & CRN").Range("N149").Select ActiveCell.FormulaR1C1 = "FALSE" End Sub
And also
But this still executes on the active sheet rather than sheet4 ("INV & CRN")![]()
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) With ThisWorkbook.Sheets("INV & CRN") Range("N149").Select ActiveCell.FormulaR1C1 = "FALSE" End With End Sub
Any help would be appreciated
Kind regards
V











LinkBack URL
About LinkBacks

Register To Reply

Bookmarks