VBA to return only values over £500 / under -£500 (including against multiple lines with the same reference)

dids86

New Member
Joined
Aug 15, 2024
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'd like to be able to run a VBA that returns all transaction lines that are over £500 and under -£500 (highlighted in green below)

What makes it slightly trickier is some invoices will be across multiple rows (138XXX for example) and I'd need to include these as well

1742900558684.png


Any help would be greatly appreciated

Thanks

Tom
 
Hello,

I also read your previous post, but why do you want to use VBA ?

You could do this with simple formulas or Pivot tables or PowerQuery. It's more "Excel-friendly" & cross-platform.
 
Upvote 0
You can do this pretty easily without VBA using the new FILTER function, if you add a "helper" column to the end of your original data.
So, in cell E5, enter this formula and copy down to to get the total for each distinct invoice:
Excel Formula:
=SUMIFS(D:D,A:A,A4,C:C,C4)

Then, enter this FILTER formula to enter the records you want (I put this formula in cell H4):
Excel Formula:
=FILTER(A4:D10,ABS(E4:E10)>=500,"")

Here is what the results look like:
1742912621081.png
 
Upvote 0
Solution
You can do this pretty easily without VBA using the new FILTER function, if you add a "helper" column to the end of your original data.
So, in cell E5, enter this formula and copy down to to get the total for each distinct invoice:
Excel Formula:
=SUMIFS(D:D,A:A,A4,C:C,C4)

Then, enter this FILTER formula to enter the records you want (I put this formula in cell H4):
Excel Formula:
=FILTER(A4:D10,ABS(E4:E10)>=500,"")

Here is what the results look like:
View attachment 123689
That's great thank you
 
Upvote 0
Hello,

I also read your previous post, but why do you want to use VBA ?

You could do this with simple formulas or Pivot tables or PowerQuery. It's more "Excel-friendly" & cross-platform.
Thanks Saboh, I've decided to go down the PowerQuery Route which looks to have worked 👍
 
Upvote 0

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