Macro to automate Multiple "IF Formula"

NeilATaylor

Board Regular
Joined
Aug 7, 2007
Messages
185
Good afternoon,

I would really like to see a macro that does the following, I'm sure someone has something already like this, if so, please share!

I have a worksheet of 5 columns. What I would like to do is subtotal an amount in column d, where the item code in column b are the same. Lets say there are 5 rows with code 8150 in column b, I want to add all these rows up BUT ALSO add up any rows which are 8150+1 (x+1) i.e. 8151. All transactions where the code in column B, x + (x+1) = 0. All true results should then be cut and pasted into a new worksheet (one worksheet for all transactions that are true).

e.g.

8150 1233
8150 12
8150 644
8151 -2084
8151 -10
8151 -205

Total of above amounts is zero, therefore cut and paste to new spreadsheet.

Now that I think about it, its actually quite complicated.

Any ideas?

Thanks in advance

Neil
 
cool, I googled that and realise the difference between long and integer.
my new error is now the error message "Run Time 1004 : AutoFilter method of range class failed"
Sorry for this tedious step by step problem solving process. I ordered a VBA for dummies book yesterday, should have it in a few days...
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You'll get that error if you try to filter for a value that isn't contained in your list.

I'm guessing you need to adjust the Field # in:

Code:
Sheets("Other Sheet").Range("B1").AutoFilter Field:=1

If you're filtering column C for the criterion, the Field should be 3, etc...
 
Upvote 0

Forum statistics

Threads
1,216,272
Messages
6,129,822
Members
449,538
Latest member
cookie2956

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