what is wrong with this macro? keep getting error alerts popping up

donggri84

New Member
Joined
Jul 31, 2013
Messages
18
I haven't created this macro and I'm a real newb with coding so I don't really know what part of this is incorrect that I keep getting error alerts
Could anyone help?
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("B23:HN23")) Is Nothing Then
If UCase(Target.Value) = "SAMPLE" Then
    MsgBox ("Please fill the next column!")
End If
End Sub
Error says "Block if without end if"
I have no idea what that means

Thank you
kind regards
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
It basically means what it says - you have two If... statements but only one closing End If - you need two:
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("B23:HN23")) Is Nothing Then
    If UCase(Target.Value) = "SAMPLE" Then
        MsgBox ("Please fill the next column!")
    End If
End If
End Sub
 
Upvote 0
It basically means what it says - you have two If... statements but only one closing End If - you need two:
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("B23:HN23")) Is Nothing Then
    If UCase(Target.Value) = "SAMPLE" Then
        MsgBox ("Please fill the next column!")
    End If
End If
End Sub

Ahhhh!!!!
Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top