MACRO Filtering Table with Msgbox

Rayreloj10

New Member
Joined
Jun 26, 2023
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
I got my macro working in filtering my table upon clicking vbYes in my Msgbox. However, I'm confused bcoz sometimes it filter the other column and obviously I get incorrect filter. Count the column manully correct the code and its worked again and when you tried again will filter another column again.

by the way, im working with multiple excel files here and the code is pretty much the same. I really appriciate someone who can give me explanation here what's happening? is this because of the same coding? I got this vba code below, so as you can see the field is =16 but sometimes it filter =15, this happened after I code the other file. although the field is different, still the filtering is changing.

VBA Code:
If NotificationMsg <> "" Then
        If MsgBox("REMINDER:" & " (" & Range("V1") & ")" & " " & " INCOMING PENDING LETTERS." & vbCrLf & vbCrLf & "Would you like to view pending letter(s)?" & vbCrLf & vbCrLf, vbExclamation + vbYesNo, "Pending Letter Reminder") = vbYes Then
        Worksheets("Register").Range("A4").AutoFilter Field:=16, Criteria1:="OPEN"
          bWarning = True
          
          Else: Worksheets("Register").AutoFilterMode = False
             ActiveSheet.Range("$B$4:$T$3000").AutoFilter Field:=16
             Range("B5").End(xlDown).Select
             lngLastRow = ActiveCell.Row
             Rows(lngLastRow).Select
             Cells(lngLastRow, "B").Select
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
The column number to filter starts from the first column of the range to filter.
In one filter you have A4 and in the other you have B4.
They should both start in columna A:

Rich (BB code):
If NotificationMsg <> "" Then
        If MsgBox("REMINDER:" & " (" & Range("V1") & ")" & " " & " INCOMING PENDING LETTERS." & vbCrLf & vbCrLf & "Would you like to view pending letter(s)?" & vbCrLf & vbCrLf, vbExclamation + vbYesNo, "Pending Letter Reminder") = vbYes Then
        Worksheets("Register").Range("A4").AutoFilter Field:=16, Criteria1:="OPEN"
          bWarning = True
         
          Else: Worksheets("Register").AutoFilterMode = False
             ActiveSheet.Range("$A$4:$T$3000").AutoFilter Field:=16
             Range("B5").End(xlDown).Select
             lngLastRow = ActiveCell.Row
             Rows(lngLastRow).Select
             Cells(lngLastRow, "B").Select
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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