Creating Error popup button

Raj2003

New Member
Joined
Nov 15, 2018
Messages
19
Hi everyone,

I need help in creating popup button for certain error...
Error : If cell value is 1 for 2 consecutive cells in a particular column.. error message button should popup

Regards
Keen learner
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Assuming you are referring to column A
Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  12/16/2020  1:37:57 PM  EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub

If Target.Column = 1 Then

If Target.Value = Target.Offset(-1).Value Then MsgBox "You entered the value " & Target.Value & "  In the cell above"
End If
End Sub
 
Upvote 0
Hi there,

Thanks a lot for the solution but when the cell value is entered ,it is asking for debugging as I enter the value in the first cell.Below is the screen shot for your reference.



1608231132415.png
 

Attachments

  • 1608231002744.png
    1608231002744.png
    115.7 KB · Views: 4
  • 13.jpg
    13.jpg
    147.5 KB · Views: 3
  • 1234.jpg
    1234.jpg
    58.7 KB · Views: 4
Upvote 0
Try this:
Not sure why you want it this way but here is what you were trying to do.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  12/17/2020  4:32:32 PM  EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub

    If Target.Column = 1 Then

        If Target.Value = Target.Offset(-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
End If
End Sub
 
Upvote 0
Try this:
Not sure why you want it this way but here is what you were trying to do.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  12/17/2020  4:32:32 PM  EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub

    If Target.Column = 1 Then

        If Target.Value = Target.Offset(-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
End If
End Sub
I think you have mistake first you specific the column a then offset -1 this means move before column a there is not existed column before a am I right or wrong? your code doesn't work at all even if select another column like in post #3 you have a typo should be put comma this works for me
VBA Code:
If Target.Value = Target.Offset(,-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
 
Upvote 0
I think you have mistake first you specific the column a then offset -1 this means move before column a there is not existed column before a am I right or wrong? your code doesn't work at all even if select another column like in post #3 you have a typo should be put comma this works for me
VBA Code:
If Target.Value = Target.Offset(,-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"

I think you have mistake first you specific the column a then offset -1 this means move before column a there is not existed column before a am I right or wrong? your code doesn't work at all even if select another column like in post #3 you have a typo should be put comma this works for me
VBA Code:
If Target.Value = Target.Offset(,-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
I test all my scripts and this script works. Target.Offset(-1)
Means the cell above
 
Upvote 0
It will fail if you change the value in row 1, which is what the OP said happened.
 
Upvote 0
ahh sorry buddy :eek:
I misunderstood , I think the mistake in post#3 it starts from a1 that's why it shows error nothing moves before a1 , right or wrong?
 
Upvote 0
Try this it is true if you enter a value in Row 1 the script would error out.
So try this
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  12/17/2020  5:08:12 PM  EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 1 And Target.Row > 1 Then

        If Target.Value = Target.Offset(-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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