TraceyH
05-20-2021, 07:29 AM
Hi all. I'm new to VBA so would really appreciate it if someone could have a look at my code and let me know why I'm getting a syntax error - have been staring at it for AGES and can't see where I've gone wrong, so any help would be hugely appreciated!! I've pasted the code below and highlighted in red the syntax issue.
Option Explicit
Dim EventRow As Long, EventCol As Long
Sub Event_SaveUpdate()
With Form
If .Range("E7").Value = Empty Then
MsgBox "Please choose a name for the event (from the list provided) BEFORE saving"
Exit Sub
End If
If .Range("B5").Value = Empty Then 'New Event
.Range("D3").Value = .Range("B6").Value 'Event ID
EventRow = .Range("C99999").End(xlUp).Row + 1 'Find first row without data
Data.Range("C" & EventRow).Value = .Range("B6").Value 'Event ID
Else 'Existing Event
EventRow = .Range("B5").Value 'Event Row
End If
For EventCol = 3 To 27
Data.Cells(EventRow, EventCol).Value = .Range(Data.Cells(1, EventCol.value).Value 'Add event to Data sheet
Next EventCol
.Range("B3").Value = True 'Event Update to TRUE
.Range("E5").Value = .Range("E7").Value 'Event Name in Drop Down List
.Range("B3").Value = False 'Event Update to FALSE
End With
End Sub
Option Explicit
Dim EventRow As Long, EventCol As Long
Sub Event_SaveUpdate()
With Form
If .Range("E7").Value = Empty Then
MsgBox "Please choose a name for the event (from the list provided) BEFORE saving"
Exit Sub
End If
If .Range("B5").Value = Empty Then 'New Event
.Range("D3").Value = .Range("B6").Value 'Event ID
EventRow = .Range("C99999").End(xlUp).Row + 1 'Find first row without data
Data.Range("C" & EventRow).Value = .Range("B6").Value 'Event ID
Else 'Existing Event
EventRow = .Range("B5").Value 'Event Row
End If
For EventCol = 3 To 27
Data.Cells(EventRow, EventCol).Value = .Range(Data.Cells(1, EventCol.value).Value 'Add event to Data sheet
Next EventCol
.Range("B3").Value = True 'Event Update to TRUE
.Range("E5").Value = .Range("E7").Value 'Event Name in Drop Down List
.Range("B3").Value = False 'Event Update to FALSE
End With
End Sub