vb help

I get the following error message, please can you help?

"End if without block if"

Private Sub CommandButton2_Click()
Set rngStart = Cells(ActiveCell.Row, "B")
    With rngStart
   If .Offset(, 16).Value <> "" Then MsgBox "Column R has Already been entered"
   If .Offset(, 0).Value = "" Then Exit Sub
   
   Exit Sub
End If
     UserForm1.Show
End With
End Sub

What should happen is:-

Column B is blank "" then exit sub
Column R is  not blank then msg box  "Column R has Already been entered"

Anything else useform 1 should show.
help1.xls
Kiwi-123Asked:
Who is Participating?
 
nutschConnect With a Mentor Commented:
this should be fine, moving two lines up.

Private Sub CommandButton2_Click()
Set rngStart = Cells(ActiveCell.Row, "B")
    With rngStart
   If .Offset(, 16).Value <> "" Then 
MsgBox "Column R has Already been entered"
   Exit Sub
End If

   If .Offset(, 0).Value = "" Then Exit Sub
   

     UserForm1.Show
End With
End Sub

Open in new window

0
 
Kiwi-123Author Commented:
Many thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.