I am getting an else without if error, but I only have one if. Can anyone tell me what I am missing here?
VBA Code:
If Me.ComboBox1.Value > "" And Me.departure1.Value > "" Then
Set myArray = ufd.Range("Truck_1")
For z = 1 To i
n = 0
Set addMe = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
addMe.Value = z
addMe.Offset(n, 1).Value = myArray(z, 2)
addMe.Offset(n, 2).Value = myArray(z, 4)
addMe.HorizontalAlignment = xlCenter
addMe.Offset(n, 2).HorizontalAlignment = xlCenter
Next z
Set addMe = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(-z + 2, 0)
addMe.Offset(0, 3).Value = ComboBox1.Value
addMe.Offset(0, 4).Value = departure1.Value
addMe.Offset(i, 0).Value = "helloworld"
'black line
With addMe.Offset(i, 0).EntireRow.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
End With
addMe.Offset(0, 3).Resize(z - 1).Merge
With addMe.Offset(0, 3)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.MergeCells = True
.WrapText = True
End With
addMe.Offset(0, 4).Resize(z - 1).Merge
With addMe.Offset(0, 4)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.MergeCells = True
.WrapText = True
End With
With addMe.Resize(z - 1, 5).Borders.LineStyle = xlContinuous
Else
MsgBox "Please make sure to select a first truck and departure time.", vbOKOnly + vbInformation, "Error"
Exit Sub
End If
End Sub