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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,224,813
Messages
6,181,111
Members
453,021
Latest member
Justyna P

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