Vba code for automatic pop up message

bunienie

New Member
Joined
Oct 12, 2022
Messages
1
Hi everyone!

I am new here. I would like to ask if someone could provde me vba codes for an automatic pop up message. I have data from range E2:PO150, and I put a conditional formatting to highlight entire row to red once a certain condition is met. With that, I would also like to add a pop up message function once any of the rows of my table are highlighted . The message is to remind user to delete those highlighted rows.

Thanks.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Welcome to the Board!

Instead of having an automated message pop-up telling them to delete the row, would it better to have automation just delete that row?

Regardless of which way you want to go, we need more information.
What exactly is your Conditional Formatting rule?
How is the data in your range being updated (manually entered in, results of formulas changing, hyperlinks, etc)?
 
Upvote 0
Try this code in Workbook...

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim i As Long
Dim lastRow As Integer

lastRow = ActiveSheet.Cells(Rows.Count, 5).End(xlUp).Row

 For i = lastRow To 2 Step -1 'Step --1 tells VBA to loop in reverse
'MsgBox (Cells(i, 5) & " " & Cells(i, 5).Interior.ColorIndex)
    If ActiveSheet.Cells(i, 5).Interior.ColorIndex = "3" Then
       MsgBox ("Row " & i & " is Highlited and will be deleted")
       Rows(i).EntireRow.Delete     
       i = i + 1
    End If

Next i
End Sub

or...

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim i As Long
Dim lastRow As Integer

lastRow = ActiveSheet.Cells(Rows.Count, 5).End(xlUp).Row

 For i = lastRow To 2 Step -1 'Step --1 tells VBA to loop in reverse
'MsgBox (Cells(i, 5) & " " & Cells(i, 5).Interior.ColorIndex)
    If ActiveSheet.Cells(i, 5).Interior.ColorIndex = "3" Then
       'MsgBox ("Row " & i & " is Highlited and will be deleted") ' To delete everything
       Rows(i).EntireRow.Delete       
       i = i + 1
    End If

Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

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