Compacting a routine in vba

rfletcher35

Active Member
Joined
Jul 20, 2011
Messages
300
Office Version
  1. 365
Platform
  1. Windows
Hi guys I have the following routine

ActiveSheet.Range("$A$3:$J$10000").AutoFilter Field:=9, Criteria1:=Array("=" _
), Operator:=xlFilterValues, Criteria2:=Array(1, "1/31/2021")
Range("M1").Select
Selection.Copy
Sheets("The Omerta Group").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

This routine filters on column 9 for January, copies a subtotal figure M1, then goes to another sheet and pastes that information for me into a required cell C2.
This repeats for Feb - Dec and pastes the detail in then next cell down on the other sheet, C3, C4, C5.......

As you can imagine this routine occurs 12 time and I was wondering if someone knew of a way to condense all this?

I ask as I also need to add this routine for around 6 or 7 sheets for other company names

Thanks

Fletch
 
The filter is being applied to "$A$3:$J$10000" and the SubTotal to "$I$4:$I$8000".
Do you have data in rows 8001-10000 ?
What happens if you extend the M1 formula to 10000 ?
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
And what exactly is the filter that you need?
As far as I can see your original fiter is last day of the month?
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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