Filter range and copy to another worksheet

robertmwaring2

Board Regular
Joined
Mar 8, 2019
Messages
132
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have been working on a project for some time now. It is bascially finished - thanks to much help from you all, and the macro recorder function in excel.

I used that function to come up with the following code which selects a column of data that contains blanks intermitently throughout the data, filters out the blanks, and copies it to another worksheet in the same workbook.
This happens four times and use the same code for each instance changing the range references, of course. It does, however, seem to take a bit of time to run - and depending on the machine the workbook is run from, it can be quite long I'm noticing. Is there a way to possibly stremline it so it runs a bit smoother? Or do I just need to suck it up and deal with it.

Sheets("Info Sheet").Activate
Sheets("Info Sheet").Range("AKW1:AKW756").Select
Selection.AutoFilter
Sheets("Info Sheet").Range("$AKW$1:$AKW$756").AutoFilter Field:=1, Criteria1:="<>"
Sheets("Info Sheet").Range("AKW1:AKW756").Select
Selection.Copy
Sheets("Production Sheet").Range("G8").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Info Sheet").Range("$AKW$1:$AKW$756").AutoFilter Field:=1
Application.CutCopyMode = False
Selection.AutoFilter

Some details that may help:

Workbook Name : Master Production Sheet
Sheet 1 Name (Hidden) : Info Sheet
Sheet 2 Name (Visible) : Welcome
Sheet 3 Name (Very Hidden) : Production Sheet

The above code is set in a Module <Module 1> that runs when a button on a UserForm <UFProductionSheet> is pressed. The Userform is accessed Sheet 2 ("Welcome") as all others are hidden.

Thanks in advance for any assistance - I truly appreciate it

Robert
 
Last edited by a moderator:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
AutoFilter...?
Check out using Advanced Filter using the copy to destination option.
 
Upvote 0
Doing away with l those activates and selects should speed up the code a bit :biggrin:



Code:
    Application.ScreenUpdating = False
    
    With Sheets("Info Sheet").Range("$AKW$1:$AKW$756")
        .AutoFilter Field:=1, Criteria1:="<>"
        .Copy
    Sheets("Production Sheet").Range("G8").PasteSpecial Paste:=xlPasteValues
        .AutoFilter
    End With
    
    With Application
        .CutCopyMode = False
        .ScreenUpdating = True
    End With

Btw, I removed the last Info Sheet autofilter as you have no criteria so I don't know what you were trying to do with it.
 
Upvote 0
Solution
@MARK858
Thank you kindly. I'm still learning and I expect I will always be as it appears there is so much this can do. This was all basically like reading chinese to me in the beginning. While your code makes perfect sence to me when I read it now, I still don't have the knowledge to think that way yet. In any case, I appreciate the assistance. I've been spending the day researching and trying to streamline much of what I spent weeks doing. I find I rather enjot this, lol.
Thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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