Excel function that copies rows if their value > 10

Biggy

New Member
Joined
Feb 14, 2014
Messages
22
Hello Excel specialists,

I got number of sheets. In one I have list of invoices and relevant information about them. Second sheet is clients information list and third is list with overdue payments. Below I added screenshots to better understand situation:

Invoice List Example:
Invoice%20list_zpsuicjjorr.jpg


Client List Example:
Buyer%20list_zpsmjl50tu0.jpg


Overdue Invoice List Example:
Whats%20necessary_zps0nslplv0.jpg


I need to auto index-match rows from the Invoice list who are overdue more than 10 days. I know that index-match should be used, but I don't now exactly how. How formula changes in case if it's necessary to set day range, e.g. 5-10?

Thank You and hopefully someone will be able to help.

Sincerely,
Tony
 
Sorry, I'm late today.
It is good to hear you want to learn as you go. That's part of the reason I like to keep it simple but I think we may be over-stepping 'simple' with the following. That said, all the code does is automate the process of filter on/off and setting the value to filter with.


Code:
Option Explicit
Sub ToggleFilter()
    Dim rng As Range
    Dim Lrow


    With Sheets("Invoice_List")
        Lrow = .UsedRange.Rows.Count    'last row number
        If Not .AutoFilterMode Then    'if not filtered then turn on and filter
            'autofilter on value store in named range OverdueDays
            .Range("$A$1:$K$" & Lrow).AutoFilter Field:=7, _
                            Criteria1:=">=" & Range("OverdueDays").Value
        Else    'if filter is on
                'turn filter off
            .AutoFilterMode = False
        End If
    End With
End Sub

1) Paste the above code in a regular module in the relevant workbook
Copy the code
[Alt]/[F11]
[Alt]/I/M (or click Insert, Module)
Paste the code

2) Back on your Invoice_List sheet
Click on the Developer Tab (if you don't have it visible and don't know how)

3) Click 'Insert', which will pop open a forms control menu
4) Click the 'Button (Form Control), which should be top left (your cursor as you move across cells will now be a cross)
5) Where you wish to create the button, click where you want the top left corner and (holding the mouse button) drag the size you want
6) When you release your mouse button an 'Assign Macro' menu will open. Click on 'ToggleFilter', Click OK
7) The button will still be selected (circles and squares on the border). While in this state drag or resize it.
8) Right-click the button Choose 'Edit Text' and change the text on the face of the button (I suggest 'Toggle Filter')
9) Click a cell. Click the macro button a few times to test whether you like the location. If you don't like the location, Click Design Mode on Developer Tab then move it.

NOTES:
A) The VBA code will look for OverdueDays with a value in it so, create a named range 'OverdueDays' on a single cell and enter a number in it (use 10 to start but change it any time).
B) The macro button does not have to be on the 'Invoice_List' sheet but it is easier to see when it is on/off in that location. Thee are ways you could make it obvious from another sheet whether the filter is on or off. You could also record a nothing important macro, set a keystroke combination and modify the macro to call ToggleFilter(), doing away with the need for a button.
C) The Index Match & Match formula needs to be in place and also needs to use OverdueDays
D) The formula in cell H2 is:
Code:
=IF($G2>=[COLOR=#008000]OverdueDays[/COLOR],INDEX(Client_List!$A:$K,MATCH($B2,Client_List!$A:$A,0),MATCH(H$1,Client_List!$1:$1,0)),"")
Copy this across and down.
D) I just realised I was a bit lazy using "$A$1:$K$" & Lrow in the VBA. In the perfect world I would have made that dynamic but it does not effect the filter

Subject to your data samples covering the right range and the column number for overdue days not changing, clicking the macro button should toggle the filter on/off. With the filter on, you can filter other columns (e.g. if you wish to chat with Client 1 about all OverdueDays invoices, click the relevant down-arrow in the relevant column and check off everyone else (note a small funnel appears on the icon next to the down arrow of filtered columns). If you get lost with filters applied, toggle off, toggle on and you are back at the beginning.
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello Steve,

I can't say enough Thank You to You! You are unbelievable helpful and understanding. Thanx for all the answers and explanations, now I will try to get my head wrapped around all of this and modify it for different scenarios, so I know what I should do next time when I got similar situation and in that way I can learn something. Once again - Thank You and You are just great!

Sincerely,
Tony
 
Upvote 0
I should also have mentioned that if you use the filter, the extra steps involved in evaluating an If() are no longer essential (but you may want to retain it when the filter is off for other reasons).

The formula at H2 copied over all other IM&M (Index Match & Match) formula would become as follows if you want the IM&M formula to show every users details with the filter off (i.e. not suppress the in-time user details). There may be advantages either way such as a if you see a sheet clear of user details with the filter off, it means you are up-to-date.

=INDEX(Client_List!$A:$K,MATCH($B2,Client_List!$A:$A,0),MATCH(H$1,Client_List!$1:$1,0))

If you want to learn VBA, aside from reading other people's code start with the macro recorder. Articles like the one on the following link can help you with the transition from recorded code to flexible VBA solutions.

How to Modify a Recorded Macro

Never underestimate the value of manuals. In order (paid for by work) I worked through Access, Access VBA, Excel, Excel VBA (learned Access and Excel in reverse order to most). MrExcel does have a store if you wish to learn that way While I have not used any of the books, it would be remiss of me to suggest the advantage of learning through books and not alert you to the store's existence. I can't say whether the books are simple to understand but I am confident authors are quality programmers and, unlike a manual bought from a bookstore, you can be confident there is direct assistance via the forum relating to any products you buy.

The other thing that will help is to develop a library of sample workbooks and an organised database of code snippets.
 
Upvote 0
Hey,

There is a way to do this without getting blank rows for the ones which are not present. It involves the use of array formula. Do let me know in case that will be of help to you. Basically you will only get results if your criteria matches otherwise there will be no results and there will be no blank rows for entries that do not match the criteria.

Thanks
Reuben
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,428
Members
448,961
Latest member
nzskater

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