[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

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
0
Kiwi-123
Asked:
Kiwi-123
1 Solution
 
nutschCommented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now