Autofilter & Copy Macro
Jul 19, 2007
I have a main workbook with 40,000 lines of data for various locations. Column A shows the locations. They all have the same fields in column B to N
I am looking for a macro that will filter on column A (Location name) & for every location in that’s in there,
Copy it, open a new worksheet, paste the data for that location into it, plus, name the tab the same as the location name that’s been pasted in there.
I attach a workbook, of desired results.
View 12 Replies
ADVERTISEMENT
Feb 4, 2007
I'm having in trying to run a macro. The macro entails a simple copy and paste special over to a new worksheet. I used the auto filter as well to get rid of the non-blanks. It works fine when I copy and paste special over to the new worksheet, but as soon as I run the macro, it doesn't copy over and returns an error.
Range("A1").Select
Sheets("FEF").Select
Rows("1:390").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="<>"
Selection.AutoFilter Field:=5
Selection.copy
Selection.AutoFilter Field:=5, Criteria1:="<>"
Sheets("FEFFinished").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub
View 2 Replies
View Related
Aug 20, 2014
I can select the top cell in column "F" after filtering by multiple columns using VBA and arrays, but now want to I want to use the top cell in column "F" to search for all other equipment that uses this item.
E.g. remove filter, and reapply autofilter to column "F" based on selected cell as per below VBA
Note: Row 1 contains command buttons and row 2 Headers.
View 4 Replies
View Related
Jul 6, 2007
I want to be able to Autofilter a specific criteria and copy over to another sheet without the header, then in the first column it'll change the information to a date, then copy back over to a third sheet. I have accomplished all of that.
My problem lies with that if there is no contents when the Autofilter is applied, it will still continue to do the steps and then I have Run-time error '1004' AutoFill method of Range class failed. Because there is no contents it tries to do this.
View 9 Replies
View Related
Oct 25, 2012
Wondering if there's a macro that can do this when i press a button.
In spreadsheet "Complete Backlog"Autofilter onShow rows where WIP Status (Column K) equals "Closed"Cut rowsPaste into next available row of "Closed Jobs" spreadsheet. No overwrites.
Or you could switch step 5 and 6 so that the rows are copied over to "Closed Jobs" and then deleted from "Complete Backlog".
View 1 Replies
View Related
Aug 10, 2005
Trying to filter list and copy filtered data to another sheet in the same workbook.
I'm receiving this error:
Run-time error '438'
Object doesn't support this property or method
Worksheets("Data"). CurrentRegion.Copy _
Worksheets(" Totals"). Range("A1")
Sub GetTotals() ..............
View 9 Replies
View Related
Jul 6, 2007
I have 2 sheets. The first sheet contains rows of data that I wish to search (Query Results) through and find matching data. The second sheet is the source of the data I want to find (Notifications). I want to take the number located in column A on sheet 2 and then use it to auto filter the rows on sheet 1. With the range that is left visible on sheet 1 I want to select the first row (can offset(1,0) to remove the headers, and paste the selected row back in to Sheet 2 ontop of the row where I sourced the original number to filter by.
Once the item is pasted I then want to pick up the next number from Sheet2 to repeat the process until all numbers have been processed in Sheet2. I have been going round the block on this for the past few days!
Sheets("Query Results").Select
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Selection.AutoFilter Field:=1, Criteria1:=vFroID
Selection.AutoFilter Field:=15, Criteria1:=vReqData
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible)
On Error Goto 0
End With
vDestRow = "A" & vLoopCount
If rng2 Is Nothing Then
MsgBox "No data to copy"
Else
Set rng = ActiveSheet.AutoFilter.Range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Proposed Notifications").Range(vDestRow)
End If
vLoopCount = vLoopCount + 1
View 3 Replies
View Related
Jan 29, 2008
The error above comes up every time I copy filtered data to a new worksheet. It does its work but the said error comes up.
Sub AUTOFILTER_withouthead()
' AUTOFILTER_for_drop Macro
' Macro recorded 1/27/2008 by DD
Dim ws As Worksheet, wd As Variant
Set ws = Worksheets((Worksheets("Destination"). Cells(1, 6).Value))
Set wd = Worksheets("Destination").Range("A1:F65000") ...
View 3 Replies
View Related
Feb 15, 2008
I am experiencing a problem with the autofilter function, but ONLY in Excel 2007. The "visual" filter works fine, but using the filtered range is a no go i.e selecting, copying and deleting an autofiltered range. The trouble is that the autofiltered range also includes all the (in this case) rows in between the target rows, which then means that the filter is more or less useless as a range selection tool.
Example code which was originally developed by Dave H.:
'Filter rows with autofilter
With ActiveSheet
.AutoFilterMode = False
With .Range("B5:N5")
.AutoFilter
.AutoFilter Field:=13, Criteria1:="Criteria"
End With
.AutoFilter.Range.Select
View 9 Replies
View Related
Apr 25, 2008
In 2003 when you use autofilter and then tried to copy the resultant information, you would only get the visible items that remain as a result of the filter. For example if you have a list of employees in alpabetical order in Column A and then in Column B you have the State in which they are employeed. Now if I use auto filter and filter on Column B to get all employees in the state of Ohio, that is all that will be visible on the screen. Perfect that is what I want. Now I want to copy all of these employees and paste them into another document or spreadsheet. (don't forget that because the list is sorted by employee all employees in Ohio are not next to eachother in the list so there are a bunch of rows that have been filtered out. and for the sake of explaining the dilema here we will not resort the list as this is a very basic example of the problem that I am having and resorting the list may not work in every case.)
In 2003 I would simply select the top left cell in the list and hit Control+Shift+End to select the all of the results and then simply copy this over to another spread sheet and I will get exactly what I was looking for. In 2007 if I go through this same process, and paste the data to another location, all of the data, even the rows that were filtered out, will come through. The whole purpose of the autofilter is to weed out what you don't want. However in 2007 this does not work in 2007.
View 3 Replies
View Related
Feb 12, 2010
1) This spreadsheet has 7 main sheets, UK, IBE, FIN, BENE, FRA.
2) Each main sheet has 8 sub sheets i.e UK CAT A to H, IBE CAT A to H etc.
3) col BO on the main sheets will have CAT A,B to H and can contain some other text but i'm only concerned about the CAT. Also Cat may be wrote CAT, cat or Cat etc
At the moment i'm using a loop, I had some code from another thread yesterday but this code creates new sheets if it can not find a sheet named the same
I will need to run this as 1 i.e all 7 together or 1 at a time.
View 14 Replies
View Related
Jul 1, 2013
I have a sheet that I need to routinely filter for a specific code then paste it into a different sheet in the same workbook. I would love to set up a simple macro that would do this for me, but I can't seem to figure it out.
In the results I would like the header row if at all possible, but I can always just make it part of the macro.
View 2 Replies
View Related
Mar 21, 2007
In between a long VBA macro, I need to copy the result of autofiltering i.e. the visible cells / rows only, to paste on an other sheet.
If I do this manualy it works but if I record this on a macro, it records the absolute cells range I pick, when in fact the result of the filtering is different every time.
View 9 Replies
View Related
Aug 9, 2007
I have created a macro some time ago that is an integrated part of an XLA. The Xla has worked fine but now, for some reason, the macro fails to import the specified text, it doesn't fail but nothing gets imported. I have tried solving this myself, but alas I am not bright enough
The code is:
Sub GetWorksheet()
Dim filetoopen As String
Dim wb As Workbook
filetoopen = Application _
. GetOpenFilename("XL Files (*.xls), *.xls")
On Error Resume Next
View 5 Replies
View Related
Aug 19, 2014
I have a workbook that has several sheets in it with various rows of data on each sheet. I would like to have a macro to loop through all the sheets in the workbook and copy and paste the rows into a new summary sheet. The rows to be copied should only have data in Column A, in other words if Column A of a row is blank I want it skipped. Also Row 1 of every sheet contains my headers, and I am only using columns A through M. It needs to be able to copy rows even when autofilter is in use.
View 13 Replies
View Related
Apr 5, 2013
I got the following code from Use AutoFilter to filter and copy the results to a existing worksheet and would like to incorporate this into my VBA project. The problem however is that this code were written to perform on one workbook and this is where my problem is. My project is between two different workbooks and cannot seem to get this code modified to do what it is supposed to do between these two workbooks. Everything I have tried so far failed. In short what this code would do is to check the existing data on the one sheet (the source) and extract only the data which is meeting my set criteria, and copy this data to the destination sheet. This is what I would like to do between two workbooks. With this the sample code as provided by Ron de Bruin. The sample workbook could be accessed trough the following link [URL]..... With this the code for matching and copying on one workbook.
Code:
Option Explicit
'>>
'This example will copy the filter results below the existing data on the destination sheet.
'Note the sheet "RecordsOfTheNetherlands" must exist in your workbook.
'This example will not copy the header row each time so when you manual add the worksheet
'"RecordsOfTheNetherlands" to your workbook you must add the headers yourself on the first row.
[Code] ............
View 1 Replies
View Related
Aug 7, 2013
I need a vb code which would open different workbook automatically, autofilter the first row and select data and copy and paste in the other workbook.
View 1 Replies
View Related
May 28, 2009
I have two worksheets 1) PL dbase and 2) Waiting list. Both setup as Lists. Where Excel automatically inserts a new row as you click in the current rows...
I want to autofilter Waiting list column I for the value of "Yes"
Copy all the data autofiltered in Waiting list to the next available row(s) on worksheet PL dbase.
View 10 Replies
View Related
Jul 17, 2007
I have an Excel 2003 worksheet that has a list (Data > List > Create List), which displays the AutoFilters for each column in the list. I am seeking a macro that will filter the results (Custom > does not contain "Closed").
I would like to assign the macro to a button as the casual user might not understand the AutoFilter use.
The worksheet in VBE is defined as "Sheet3 (Audit Findings)"
My list has headers on row 7 (A7:K7)
I would like the AutoFilter to return all results except those marked as "Closed" in column K.
View 9 Replies
View Related
Jul 13, 2007
I am fighting a quixotic battle against a problem, that I realise may well be unsolvable. I have a worksheet that consists of approximately 27,000 rows in a four-level structure, like so:
1
1.1
1.1.1
1.1.1.1
To make the sheet easier to navigate I have created an expanding/collapsing tree structure by using simple hide and unhide rows, and on the last level of headings (1.1.1) I have cells that change between "+" and "-" depending on whether the fourth-level subset is currently visible or hidden. Naturally I need to keep the cell as "+" when the set is collapsed, and "-" when expanded. I have accounted for all methods user can change the hidden settings of those rows, but one:
When users autofilter the list, the +/- signs obviously screw up, because filtering resets the user-set hidden-settings. Suddenly I have expanded subsets with "-" on headings that were previously "+". Now this is obviously a vanity problem, as the +/- sign is not integral to the working of this macro, but the problem is that with three different levels of headers the worksheets starts to look a little cluttered.
Finally, my question: Is there any way to trigger a procedure to reset these signs upon/after autofilter? I realize that this is not a built-in Excel event, but a workaround will do just fine. Any way to detect that an autofiltering has taken place without having to check the.
View 4 Replies
View Related
Sep 25, 2009
Im sure this is a very common problem. I tried searching for it but I havent found anything that solves this for me. Here is the code Im using:
View 3 Replies
View Related
Aug 7, 2014
My problem is following: I have a list of data that are classified according to a particular character, and I want to copy (with auto filter through the macro) the relevant information to the appropriate place in the sheet where it belongs. That's no problem. The problem is that if I want to copy data, classified by a character that is not listed in the table (that is not in the filtering criteria), then all the data are copied to the appropriate place. But I do not want to copy in this case nothing. How should such a macro look like?
Find attached an example : example.xlsm‎
View 3 Replies
View Related
Sep 15, 2009
I am trying to create a macro to autofilter a sheet based on the value a user will enter into a popup box. I have found bits of code which I have been attempting to figure out and use somehow however I am getting more lost.
I can create a basic macro to autofilter, the problem I am having is that I am unsure of how to link this to an input/popup box of some sort
View 10 Replies
View Related
Oct 22, 2013
a macro (that i will link to a control button) that will autofilter a data set. The problem i have is the macro i wrote below, It might not be the best looking macro in the world, but it would work for my purposes if i can get the part that does the autofiltering to be more dynamic. meaning, instead of a hard coding "Retail" in the macro, id like it to reference a cell so that the user can type whatever they want, then click the button and it will filter based on what they type in.
this is what i have
Sub Filter_Button()
With Sheet2
AutoFilterMode = False
Range("A6:M6").AutoFilter
Range("A6:M6").AutoFilter Field:=2, Criteria1:="Retail"
End With
End Sub
View 5 Replies
View Related
May 23, 2014
I know how to filter based on cell value, and how to auto filter "does not contain", but is it possible to combine these? i.e. Filter OUT the value of a cell from a range?
View 3 Replies
View Related
Feb 23, 2010
I am looking for a vba which will send an email to someone the minute I highlight a row in red?
View 9 Replies
View Related
Jan 9, 2007
I recorded a macro to custom AutoFilter 2 columns in a worksheet. The information will be filtered between 2 dates; i.e. >= cell B2 and <= cell C2.
Both cells are formated to dd/mm/yy so i entered 1/12/06 (for 1st Dec) in cell B2 and 31/12/06 (for 31st Dec) in cell C2.
When i enter these 2 dates, click the button to run the macro and check the custom filter in the "Planning" worksheet it appears that the dates change to 12/01/06 and 21/12/06 and no records appear - although i know at least 65 rows should show.
If i then enter the dates in B2 and C2 as mm/dd/yy instead (but leave the date format of the cell as dd/mm/yy) the filter works perfectly; i.e. enter 12/01/06 and 12/31/06. However I plan to issue this spreadsheet out to other staff and as every other date in the spreadsheet is in the uk format dd/mm/yy i dont want to confuse them by insisting they use the mm/dd/yy format for this one function.
Has anyone ever encountered this before? and if so is there some way i can fix it?
Heres the code for the filter:
Sub Monthly_Stats()
Sheets("Planning").Select
Selection.AutoFilter Field:=5, Criteria1:=">=" & Sheets("Filtered Statistics").Range("B2").Value, Operator:=xlAnd _
, Criteria2:="<=" & Sheets("Filtered Statistics").Range("C2").Value, Operator:=xlAnd
Selection.AutoFilter Field:=82, Criteria1:="<>"
End Sub
View 3 Replies
View Related
Oct 21, 2009
The code contain using Autofilter to some columns, & then copy paste to another sheet to first blank row, & sorting it by asscending in Column A.
Both sheets are in the same workbook.
But for some reason, the Macro will giving the result expected if i run it step by step (by using F8 button under window VB editor). And if i call the Macro name it stoped in the middle of the process.
View 7 Replies
View Related
Jul 7, 2006
I'm using Excel to map automotive parts to vehicle applications (two different spreadsheets) for importation into a relational Access database. Production dates for parts rarely match the on-sale dates of the cars, so I've set up a macro that:
1. copies the start production date for a part record into the vehicle workbook at the top of the 'discontinued' column,
2. copies the end production date for the part into the vehicle workbook at the top of the 'release' column,
3. uses these pasted data points as criteria for the autofilter in the vehicle workbook as 'vehicle release date' < 'part end production date' and 'vehicle discontinued date' > 'part start production date'.
I find that the macro works perfectly in the autofilter for the vehicle discontinued date, but not for filtering the vehicle release date. The date is copied and pasted OK. When I check the custom filter dialogue box, the date has been entered in with the 'is less than' menu item selected, but it doesn't bring up any records unless you click on the 'OK' button once the dialogue box is open. I want to run the macro without having to run the autofilter manually at all. To troubleshoot the issue, I broke up the macro into two separate macros, one for release and the other for discontinued. Problem remains, even though the only difference between the two macros is the relative cell addresses. I've checked formatting of the cells for text vs. numeric and that doesn't appear to be a problem.
View 4 Replies
View Related
Dec 8, 2006
Two macros have been developed in order to write entries to a sheet called Detention Register from another sheet named Database.
The first macro (AutofilterDatabase1) filters for two criteria in the Database sheet: 1. All dates 7 or more days prior to today's date (5th field called rDate) & 2. The smallest positive value for a person in field 10 (called rSmallest).
Once these filters have been applied a second macro (named WriteDetentionRegister) is supposed to write the filtered entries to a sheet called Detention Register. However, if no enties at all are found by the filter it writes all entries to the Detention Register. Is there any way of stopping the writing process if no entries at all are found after the filtering process?
I'd also prefer it if after the writing process (or not as the case may be) that all autofilters were returned to displaying 'All' data in the Database sheet for fields 5 and 10. Is this an easy tweak to make to the existing code?
I enclose the code of the 2 macros.
Sub AutoFilterDataBase1()
Application. ScreenUpdating = False
'Get today and convert to serial value, subtracting 7 days
d = CLng(Date) - 7
DBase.Activate
DBase.AutoFilterMode = False ......................
View 9 Replies
View Related