AutoFilter Macro Using Cell Content As Criteria
Oct 5, 2006
I was wondering if I could pick up the Field number and the criteria from a cell in excel rather than changing the code in VBA.
Range("A1:K1"). AutoFilter Field:=Range("A1"), Criteria1:=Range("B1")
I was trying this code but I got an error message. Does anyone know if I can pick up these information directly from excel.
View 6 Replies
ADVERTISEMENT
Oct 22, 2008
I am trying to make an "intelligent" auto filter that with filter with increasing restriction until a certain criteria is met.
The list runs from A5:G20. In coloumn G is the number of hours associated with each event. And in A1 I have the percentage of items showing/whole list so it I have 15 rows on the list, and I filter so that only 5 are showing, cell a1=33%
How can I make a macro that will autofilter until the the a1=5%
Like having filter criter = equal or greater then 1 hour,
if a1 > 5%
Then criteria + 1 hour
If A1=<5%, then stop.
basically a seed criteria of 1 hour, adding 1 hour until the value in a1 = 5%
View 6 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
Aug 21, 2007
is there a way to format a cell so that when i enter a time like 1 pm the pm does not show? this is for a schedule that will calculate the sum of hours employees have worked so i can't format the cell as text. also, i want to avoid military time (no 13:00).
View 9 Replies
View Related
Aug 18, 2008
I have one master sheet of data, with a large number of fields and data.
I need to turn this master data into individual records, each record exisiting as an individual worksheet - lets call it a 'U'. The U is a template sheet which has calculations and lookups built into it to complete further information. The completed U's are then used by a number of people for different reasons. There are 3 main 'flavours' of these sheets which have slightly different uses.
I've gone from knowing nothing about macros to having learned enough about them in the last week or so to populate each individual sheet with the data, and save the new file in the location I want it to go.
What I want to do now is filter the fields displayed by the individual U sheets, as not every field is applicable to each 'flavour'. I've marked up the rows as to the appropriate flavour - e.g. Row 17 is applicable to 'P' 'F' and 'R' ( Cell which is auto filtered contains PFR), but Row 18 is only 'P' and 'F' (Cell contains PF).
I've gone through the master file and identified each entry as a the appropriate flavour - to summarise what I'd like to do now:
1) Automatically populate the template file with the relevant data. (which my macro will do)
2) Use an autofilter to filter the rows equal to the data in the reference sheet so these are the only ones displayed. Eg. Reference sheet says 'P', so I want to filter the U sheet where autofilter column contains the letter 'P'
3) Rename the file and save as my reference in the location I want it to (which the macro is doing).
Here's what I've got:
Range("CF3").Select
Selection.Copy
Windows("USS iss1.xls").Activate
Range("G158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.AutoFilter Field:=1, Criteria1:=ActiveCell, Operator:=xlAnd
(where CF3 = the cell in the master data with the flavour in it, "USS iss1" is the template U file, G158 is a spare cell and Autofilter Field 1 contains the row reference which tells me which data applies to which flavours).
I've tried using the macro recorder, which when I paste the value in the autofilter/contains box records it as the value I've just put in rather than a copy of the reference cell. I've tried
Criteria1:=*ActiveCell*
and other variations on the same theme, but to no avail - I get "Compile error: Expected:expression".
View 3 Replies
View Related
Aug 6, 2006
I attached a small file in which I filtered on Cities. And now I am looking for a VBA to copy the filter to an empty cell. Is this possible?
View 9 Replies
View Related
Sep 12, 2007
Problem: utofilter criteria
Explanation
This has been my Autofilter criteria to date
Criteria1 = " " (needed for other macros)
Criteria2 = "=2007*" (i.e. starts with JobYear)
This works fine but now I am wanting Criteria2 to be linked to a cell where the user will enter the job year to be filtered.
Solution
My guess at solutions would be:
Criteria1 = " "
Criteria2 = Cell*
or
Criteria2 = Cell & "*"
Unfortunatley I have been unable to find any way of making this happen. Using an Autofilter to link to a cell is standard but making an Autofilter link to a cell with a starts with criteria attached doesn't seem to be doable.
View 5 Replies
View Related
Apr 29, 2008
My excel file has a column for customer name (there are more columns btw). I have the filter feature on. The customer list is in column F.
I recorded a macro by copying a customer (from the customer column, say from cell F99). Then I click on the filter arrow and select the 'custom' option and in the dialog box that comes up, I paste the copied customer and try to find other records which have the same customer name.
This works great but when I run the macro for some other customer, say from cell F200, the pasting part, pastes the customer that I had selected when recording the macro.
Is there a solution to make this generic so that the macro will work in a manner that I simply highlight the cell of the desired customer and then then run the macro which will give me the result.
View 7 Replies
View Related
Apr 28, 2014
I'm having a hard time making this maro work in Excel 2010.
I need it to filter out the items "AR", "BATCH", and the line of "Total:*" where the * is a total amount of any given number dependant on the day.
Below is the coding I have that Excel is not liking.
Sub FilterAccurateRawData()
'
' FilterAccurateRawData Macro
'
'
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AA$45415").AutoFilter Field:=1, Criteria1:=Array("<>AR", "<>BATCH", "<>Total:*")
Operator:=xlFilterValues
Sheets("Instructions").Select
Range("A9").Select
End Sub
View 3 Replies
View Related
Mar 18, 2013
I'm trying to add to my code an autofiler with multiple criteria, the criteria is held in single cell. The criteria is made up of anything from 5 to 30 cells, then i have tried to concatenate these separated by commas, in speech marks, speech marks and commas etc., set them as an array the use that in my filter, but nothing seems to work.
View 6 Replies
View Related
Feb 25, 2009
I am attempting to use a cell reference generated using the "address" function and text function (so the cell displays text only, not formula) as a means of defining the top left cell into which I want to paste a column of formulas. The reference cell is static, but the contents is dynamic.
View 3 Replies
View Related
Jan 15, 2008
I want a macro to run everytime the value in say cell D6 changes.
View 13 Replies
View Related
Aug 7, 2006
I have a drop down list made from the Forms toolbar with a list of items: 1, 2, 3, 4, 5. I have set it with a linked cell, so when you choose, say 3, from the dropdown, 3 appears in B10.
I was hoping to add a 'Go' button, which would run another macro depending on what is in B10, i.e. so if 3 was chosen, then you press 'Go', Macro3 would be run.
So I have 5 macros called Macro1 - Macro5, and I need some code for the 'Go' button which will run the right macro depending on what number is in cell B10.
View 9 Replies
View Related
Sep 12, 2007
I use this to read cell content, add some text/characters (ie. [ and ]) and change the properties of the complete cell
Sub COMMENT()
Worksheets("DVD Lijssie").Activate
If ActiveCell.Value 0 Then ' Change all in to ... ... ...
ActiveCell.FormulaR1C1 = ActiveCell.Value & " " & "]" & " " & "["
With ActiveCell.Font
.Name = "Arial Narrow"
.Size = 8
.ColorIndex = 16
End With
End If
End Sub
HOW can I change this vba-code so it leave's the content of the cell like it is and add some content with the use of let's say TexBox1 and ONLY use different font properties for the newely added content?
View 9 Replies
View Related
Nov 9, 2007
I'm trying to create a macro which will edit the content of a cell and update. I'm just using the "Record New Macro" option in tools.
It doesn't seem to perform the F2 edit function within the macro.
I'm sure this has been discussed previously, but I can't get the search function to work for me.
View 9 Replies
View Related
Nov 17, 2007
I don't know if I am asking for something impossible,but is it possible to create a MACRO to automatically add or subtract 10 to whatever number is in the cell? for example:
A1= 20
I would like to have a macro that lets you either add 10 to it to become 30 or subtract 10 to it to become 10.
View 9 Replies
View Related
Oct 20, 2008
I have a question.
What code do I need to make the data that is in more cells to be shown as data in one cell ?
ex. A5 D5 to be shown as D2(in a new workbook)
1 1 11
And that for every row?
View 9 Replies
View Related
Apr 24, 2009
I am having some trouble writing a macro to delete cell content. I know which cells I want to clear, but I can't seem to get the macro to do it.
I also want to have something in the macro that inserts data into the lines that I am trying to clear. I want cell A67 to say "Payment" and cell A71 to say "Total."This is the code I am using:
Sub DeleteCell()
Dim i As Integer
For i = 67 To 71
If Range("A" & i).Value = "--" Then
Range("A" & i).Delete
Next i
End Sub
View 9 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
Dec 14, 2006
I'm only starting to get into the Macro side of excel, and I've created a couple of macros to automatically format cell contents and the like.
However I'm having trouble trying to divide some cell contents by 100.
I have 2 files I'm working with, one contains information regarding cd's and percentages, however the percentages in this file cannot be formatted to percentages (so the powers that be say) for whatever reason.
I copy all this information into another file which does have the percentages formatted as percentages, the result is that the values get multiplied by 100.
So values that read:
100
50
50.25
for example, appear on the new sheet as:
10000%
50000%
5025%
Is it possible to write a macro that will divide these percentages by 100 so the read correctly as:
100%
50%
50.25%
the macro will have to work on selected ranges.
View 9 Replies
View Related
Feb 3, 2009
Is it possible to create a macro attached to a button that allows me to save the workbook based on content of 2 cells in the workbook?
I like to save the workbook based on content of cell A4 that contend a text string. After that saving another time with the contend of cell A4 plus cell A9 which contend the today() function. I am doing this because this workbook is constantly updated and a backup copy is done based on the date the file is save.
View 9 Replies
View Related
Apr 18, 2014
Formula/macro/etc that would enable me to have content of a cell changed based on the content of another cell in the same row.
Example: cell in column D says "PSA" - so I would need the cell in column H for that same row to read "Radio"
I would need an entire sheet scanned to review for these occurrences and make the appropriate changes. I also would need the formula to be inclusive enough to scan for variations in column D cell content (PSA 1, PSA 2, etc).
View 4 Replies
View Related
May 15, 2008
Say you have a long list of data, and you go to Data menu --> Filter --> AutoFilter
And then you want to use the Custom AutoFilter. Here's a screenshot:
[url]
Is there any way to do MORE than two autofilters?
View 12 Replies
View Related
Jul 23, 2009
Been looking at various options. Just want something to simply show the autofilter critera (1 & 2 or how every many there are) in a text box. The range being filtered is column A : M.
Basically taking this further, want to use the criteria of column C to lookup an email address e.g.
'C' is filtered by "Company 96"
Lookup "Company 96" from sheet2 range A:B, with column A containing name, and column B containing email address
View 9 Replies
View Related
Nov 23, 2007
I have a long list that has all the services from our stores. I´m using the formula below to count how many services does each store have that are over 20 days old.
=SUMPRODUCT((G!$A$2:$A$6000=$B4)*(NOT(G!$I$2:$I$6000="Valmis/Odottaa nouto"))*(NOT(G!$I$2:$I$6000="Valmis, toimitettu"))*(NOT(G!$I$2:$I$6000="Finished/WaitingDeli"))*(Päivämääärät!$C$1-G!$C$2:$C$6000>Päivämääärät!$I$3))
Now i´m wondering is it possible to make a macro that would delete all the cells in the range that do not match the criteria of my formula?
With one exception in sheet G cell A2--> has the number of the store. There are over 40 stores so each store has a number 10, 20, 30, etc...
This is the part of the formula that determines witch store it is counting
(G!$A$2:$A$6000=$B4) B4=10 in this case and B5 would be 20 and so on... By modifying that one part i can count old services for all of our stores.
Now I want the macro to delete all services from the list that are not over 20 days old and belong to the store 10 (B4). If it would delete everything that dont match that formulas criteria i could not get a list of old services for our other stores.
What i´m trying to accomplish is get a list of the services that are over 20 days old. I´m now picking them from the list by hand and that takes a really long time. Because of the number of the stores and the size of the range.
View 9 Replies
View Related
Dec 4, 2011
This is the following code i have a problem with:
ActiveSheet.Range("$B:$J").AutoFilter Field:=1, Criteria1:=Sheets("Report").Cell(0, -2).Value
I am trying to filter items on a sheet called "all the answers" and i want to look up a value on the sheet called "Report" to filter.
The cell i want to filter is two cells to the left of the active cell on that sheet.
View 5 Replies
View Related
Oct 5, 2012
I have some data which I want to apply multiple criteria to for a particular column. Searched around on the internet and it would appear I should use an array and pass that to my criteria. What I can't find an answer for is how to say "does not equal any of the values within the array"
Code currently is:
Code:
Dim NumberFilter_Array(0 to 2)
NumberFilter_Array(0) = 2
NumberFilter_Array(1) = 9
[Code].....
I've tried variations for that in red but can't get it to work, how to correct the line in red to filter for none of the values in the array NumberFilter_Array?
View 2 Replies
View Related
Nov 1, 2012
I am trying to use VBA to set an autofilter that hides all zeros in Column AL and then excludes all values in Column E that start with "312" or "502". For some reason I can't get this to work as expected, it still continues to display unwanted values in Column E.
HTML Code:
ActiveSheet.Range("$A$1:$CS" & LastRow).AutoFilter Field:=5, Criteria1:=Array("312*", "502*")
ActiveSheet.Range("$A$1:$CS" & LastRow).AutoFilter Field:=38, Criteria1:=Array("0")
View 5 Replies
View Related
Apr 30, 2014
Is there a way to add a dynamic number of criteria(based on user input) to an autofilter.
Code:
ActiveSheet.Cells(1, 1).AutoFilter Field:=1, Criteria1:= dynamicfilters
View 4 Replies
View Related
Apr 16, 2006
You posted this code and it works well
could u advise how to display just the criteria ie no heading, no :, no =, and when it displays the criteria could it fill the cell with a colour. When filter is set to "all" give a blank cell
This would over come lots complaints from operators not realizing that filters are on because they can not find the silly blue button.
Are microsoft aware of is and are they changing it in the new release.
View 9 Replies
View Related