Macro to copy and paste filtered data if there is more than 20 rows left after filtering?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
not sure if this is simple or not,
what i want to do is Filter Sheet "Data" column H on the name "Sold"
then count the number of rows visible to be copied.
if number of rows is more than 20 then messagebox " there is not enought room,
if less than 20 Call "copy macro"

so i'm trying to check the number of rows,
after the filter has been done?

any idea how to do this?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You're title suggests that you want to copy if more than 20 rows, but your description is the other way round. Which do you want?
 
Upvote 0
How about
VBA Code:
Sub tonywatson()
   With Sheets("Data")
      .Range("A1:H1").AutoFilter 8, "Sold"
      If .AutoFilter.Range.Columns(1).SpecialCells(xlVisible).Count < 21 Then
         Call copy_macro
      End If
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,212,933
Messages
6,110,751
Members
448,295
Latest member
Uzair Tahir Khan

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