I just started working with macros and the vba code. I have read online how to do what I want but when I run the code i get an error "statement invalid outside type block". Here is my code:
Maybe it has to do with my msgBox it highlights the top line in yellow, but the msgBox is highlighted in blue. Any help would be great! Thanks![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("C9:C11")) Is Nothing Then 'Do nothing if more than one cell is changed or content deleted If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub If (C9 = "x" Or c10 = "x" Or c11 = "x") Then 'display error message MsgBox("You can only select 1 yes for this category", vbOKOnly, "Error") As VbMsgBoxResult End If End If End If End Sub
Bookmarks