I would like to trigger a macro to run only after all of the cells within a given range have a value. I want to have my input range open without the values entered when the workbook was closed. Currently the code below runs when the workbook is opened.
Sub Page_Setup()
Sheet1.Unprotect
Application.EnableEvents = False
Application.ScreenUpdating = False
Sheet1.Range("Inputs").Style = "40% - Accent2"
Sheet1.Range("Calcs").Style = "40% - Accent3"
Sheet1.Range("C8:C12").Value = "-"
Sheet1.Range("Calcs").Value = "-"
Sheet1.Range("C13").Value = 64
Sheet1.Range("C14:C16").Value = 0
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
I want the macro to run once the user has entered a value in each cell from C8 to C12. Thanks in advance for any help.
Edit:
What I would like is for the macro to run only if the range "C8:C12" have a numeric value. I prefer to clear that range when the workbook is initially opened to avoid showing the values that were entered (and calculated by the macro) when the workbook was closed. The code below runs when the workbook opens up.
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Sheet1.Range("User").Value = Environ("UserName")
Sheet1.Range("Run_Date").Value = Format(Date, "mm/dd/yy")
Application.Run ("Page_Setup")
Application.ScreenUpdating = True
End Sub
Then I would like to trigger a separate macro (Case1) to run once C8:C12 all have numeric values. I have the code below
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Unprotect
Sheet2.Unprotect
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim KeyCells As Range
Set KeyCells = Worksheets("Sheet1").Range("Inputs")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
Application.Run ("Case1")
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
My problem is that Case1 will return an error if the cells do not have a numeric value. Sorry for the confusion and I hope this clarifies my question.
Worksheet.Change()In the change event, check if the user has just entered a value in C8:C12, and if all of those cells have a value, and if so invoke the macro you want. The Change event acts as a gate keeper. - John Coleman