Filtering by multiple columns

kg2586

New Member
Joined
May 4, 2018
Messages
8
Hopefully someone can help me figure this out.

We need to keep the regular file (AP Check Register) from our accounting system to complete account reconciliations. The problem with this is that when there are checks that are cut that have up to 5 or 6 accounts, once you filter on one of the columns for that specific account, the remaining columns that potentially have that account in it as well, does not show up. I've attached a sample file with sample detail. Is there any way to achieve what I want it to do? Adding a macro to add a new sheet and filtering by X criteria (account number) that searches all the account columns (Columns F,I,L,O,R,U,X,AA,AD,AG on sample file) and pulls in the account amount (Columns H,K,N,etc. of sample file) if it matches that criteria along with the Payee and other detailed columns would possibly suffice. Any help is greatly appreciated. Thanks!

Edit: I can't seem to attach a file. How do I do that?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Here's a possible sample... I want the details of each of those accounts (amount, payee, check number, etc.) that are appearing in different columns to show up when specified, whether that be a macro created, formula, filter or whatever.


[TABLE="width: 500"]
<tbody>[TR]
[TD]Account 1[/TD]
[TD]Account1 Amount[/TD]
[TD]Account2[/TD]
[TD]Account 2 Amount[/TD]
[TD]Account 3[/TD]
[TD]Account 3 amount[/TD]
[TD]Check number[/TD]
[TD]Payee[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1005000[/TD]
[TD]$5,000[/TD]
[TD]1005001[/TD]
[TD]$2,500[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1005001[/TD]
[TD]$4,500[/TD]
[TD]1005000[/TD]
[TD]$3,000[/TD]
[TD][/TD]
[TD][/TD]
[TD]101[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1005002[/TD]
[TD]$2,500[/TD]
[TD]1005000[/TD]
[TD]$2,000[/TD]
[TD]1005001[/TD]
[TD]$1,000[/TD]
[TD]102[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
See if this is what you want:
Will copy the data to a sheet which already exist named "Master"
Code:
Sub Filter_To_Sheet()
'Modified 5/4/2018 11:50 AM  EDT
Application.ScreenUpdating = False
x = InputBox("Enter account number")
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "F").End(xlUp).Row
Dim counter As Long
    
    With ActiveSheet.Range("F2:FG" & Lastrow)
            .AutoFilter 1, x
            .AutoFilter 4, x
            .AutoFilter 7, x
            .AutoFilter 10, x
            .AutoFilter 13, x
            .AutoFilter 16, x
            .AutoFilter 19, x
            .AutoFilter 22, x
            
           counter = .Columns("F").SpecialCells(xlCellTypeVisible).Count
           If counter > 1 Then
            .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Master").Cells(2, 1)
           Else
           MsgBox "No valuws found"
           End If
            .AutoFilter
        End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I got it copied in and it's failed at .AUTOFILTER 1, X saying the "autofilter method of range class failed".
 
Upvote 0
What does this mean:
I got it copied in
You saying it did copy the values into sheet named "Master"
Then you got an error?

Or it just errored out?

Do you have a sheet named "Master"
 
Upvote 0
Sorry. I got the macro inserted. I now got it to run and tells me that no values are found. I have a sheet named "Master" and after the macro runs, the columns are filtered with no data shown, so I know the macro has the correct range for filters since the 6 columns with the accounts have the filter icon.
 
Upvote 0
So let me be sure I understand what you want.

You want to look in columns
F,I,L,O,R,U,X,AA,AD,AG
And in each of these columns you want to look for the account number you entered into the Inputbox

And then copy that rows data to a sheet named "Master"

Is this correct?
 
Last edited:
Upvote 0
Now if in any of these columns it does not find the account number the script will tell you it found nothing.
 
Upvote 0
The script looks down the sheet till it finds no more data in column F
Could that be the problem?
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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