How to count advancedFilter results BEFORE applying?

Cymae

Board Regular
Joined
Oct 19, 2008
Messages
70
I have a sheet called Job List which has a list of all the jobs available. Then I have a page called "Team_Jane" which contains 3 tables that should hold Jane's Current Jobs, Pending Jobs and Completed Jobs.

I have written a bit of VBA that does an advanced filter on the Job List and puts the filtered information in and that works fine, BUT because the Current Jobs list is above the Pending Jobs list, I need to be able to insert a number of rows equal to the number of rows the advanced filter needs to add before applying the filter, or I accidentally override the pending jobs if someone has a lot of current jobs they are doing.

Does anyone know how to do this?

The code I have looks like this, and I can add a row to the CompletedJobs table, but I need to do this before the advancedfilter is applied in order to ensure there is enough space to add the extra items to the table.

I just need to replace the NumJobs integer with something that is calculated before the filter is applied.

Code:
Private Sub Worksheet_Activate()

Sheets("Job List").Range("B3:H1048575").AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Sheets("Calculations").Range("B3:H5"), CopyToRange:=Sheets("Team_Jane").Range( _
        "B21:H21"), Unique:=False
        
Dim numbJobs As Integer
numJobs = 1
Set tbl = Sheets("Team_Jane").ListObjects("Jane_completedJobs")
  
Set Rng = Range("Jane_completedJobs[#All]").Resize(tbl.Range.Rows.Count + numJobs, tbl.Range.Columns.Count)
  
tbl.Resize Rng


End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,207,402
Messages
6,078,270
Members
446,324
Latest member
JKamlet

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