AdvancedFilter Retaining Criteria In Macro
Aug 23, 2007
I realize that there are 100 posts asking this same question but I believe this question is unique. My actual data if far more complex, but I have attached a simple workbook to illustrate my problem. It is my understanding that the following code will generate a unique list of values. However, it does not work if an AdvancedFilter has been used previously in the code.
Sheets("Sheet1"). Range("B1:B6").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet2").Range("E1"), _
Unique:=True
I have been able to solve this problem by adding "CriteriaRange:=vbNullString" to the above code.
Sheets("Sheet1").Range("B1:B6").AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=vbNullString, _
CopyToRange:=Sheets("Sheet3").Range("E1"), _
Unique:=True
Here is my question: Do you need to reset the value of "CriteriaRange" each time you use AdvancedFilter, and if so, is setting CriteriaRange to vbNullString the best way to do so.
View 7 Replies
ADVERTISEMENT
Nov 12, 2006
I need to transpose into 2x2 range to use as criteria for advanced filter
I tried
arrCrit = Array("Accnt_Nmbr", "313000", "DT", "RV")
Set rngCrit = wsData.Range("IU1:IV2")
rngCrit = WorksheetFunction.Transpose(arrCrit)
Where Accnt_Nmbr and DT are Column Headers in the data to to filtered
However when I run the output includes all DT's (Document Types)
How can I expand so both criteria are used in the filter?
View 9 Replies
View Related
Feb 21, 2008
I am using advanced filter. When I use
Range("S3").Value = "" = "M6" = """"""
I get a runtime error 13. Am I missing something? After reading through other posts, I could not find anything wrong with this.
View 4 Replies
View Related
Jun 27, 2008
I am trying to achieve the following and am not certain how to achieve this in Excel 2003.
1. make the Criteria Range Dynamic in Advance Excel, so that the Filter automatically updates on every Criteria change.
2. Raw Data range is kept in Closed workbook
3. Filtered Result displayed in another Workbook.
View 2 Replies
View Related
Jul 8, 2009
I'm having with creating a macro to filter some data from one sheet to another. I used the "record a macro" function to get the code I've posted below but part of the code is always changing.
In my workbook I have a main sheet called "Data" and another sheet called "Parts". The code below does what I need it to do, but the problem is that the cell range (A2:I139) is not constant and may change depending on how many rows of information I import on the "Data" sheet.
What I'd like to have happen is either have a dialog box pop up and prompt me to select the cell range (I've tried using the Application.InputBox function but can't figure it out), or since the first cell will always be A2 and the last column will always be I, have excel automatically figure out the last row that contains data.
View 2 Replies
View Related
Aug 27, 2007
In Excel I recorded a macro by carrying out some operations and then copied the code into VBA code window to the click event of a button expecting the code would operate well but in vain. What is wrong with my operations? By cliking command button placed on a userform I want to copy the date of one column to another and the data thus copied into another column should contain only unique value.
View 4 Replies
View Related
Dec 24, 2007
I'm trying to put a search userform in a worksheet. I got this code from the web and tried to alter it to fit my worksheet....
View 7 Replies
View Related
Apr 6, 2014
I have data from Columns A to D. I want to do the
following:
1. Look for duplicates in all column A
2. For each duplicate found in column A, check if all values in column B are also duplicate.
3. If the condition in (2) is satisfied, compare column D for all the rows; select the row with the minimum value in column D, and delete the other rows.
For example:
A B C D
Row1: Abby 04/01/2014 7:00PM 0.98437
Row2: Sam 04/01/2014 9:00PM 0.35627
Row3: Abby 04/04/2014 7:00PM 0.68932[code]....
View 13 Replies
View Related
Feb 29, 2008
Is there a way that I can tell my VBA code to select the first row that my advancedfilter is showing? The row number changes, depending on the criteria selected. I need to be able to select this row, so I can hide the first row the filter is showing. I tried an offset command, but that just selects one of the rows hidden by the filter.
View 9 Replies
View Related
Jan 20, 2010
I am trying to use the advanced filter code to move all unique items from one sheet to another sheet. For example, I have two sheets named (1) "data" and (2) "output". I want to filter a list of unique items only from the "data" sheet and copy the data to column A in the "output" sheet. The code posted works fine if I keep the unique data in the same sheet, but I can't figure out how to copy to the "output" sheet.
View 2 Replies
View Related
Apr 19, 2007
I'd like to say that this Forum is helping me very much when reading so many useful topics, get help from ppl here. From nothing I advanced my program very much. About my problem here:
I have an Excel Column with Dates (dd-mmmm-yy) and an UserForm/ComboBox. I'd like to add only the unique dates from the Excel Column to the ComboBox. The Excel Column Range is updating with new dates.
I tried to use RowSource but i don't know how to get the unique dates with RowSource. Maybe RowSource is not a good decision.
View 9 Replies
View Related
Aug 9, 2007
is there any way to get an advanced filter to play with autofilters? at the moment after i have applied the advanced filter it completly messes up with my autofilter to the extent that it moves where the autofilter actually sits and then when i try and use the autofilter it completly ignores the advanced filter i just applied. how to make the 2 filters play nice together and actually be able to autofilter the results of an advanced filter.?
View 2 Replies
View Related
Sep 26, 2007
I have an auto filter setup on some data. When I perform an advanced filter either in-place or to another location, the auto filter disappears. Is it supposed to be have like that? If so is there some sort of work around?
View 2 Replies
View Related
Nov 28, 2007
I'm in the process of debugging some code at the moment and so have removed the On Error Resume Next's that I had in there.
I've since gotten rid of this where it wasn't necessary, but I have a general question about using the ShowAllData method with Advanced filter.
When I use:
ActiveSheet.ShowAllData
when there is no advanced filter applied, I get an error saying the method of Worksheet class failed.
I have searched and cannot find a way to check in VBA if there are advanced filters applied, though I can find code that will check if AutoFilters are applied. This doesn't work with AdvancedFilters.
View 4 Replies
View Related
Mar 3, 2008
I am trying to use the advanced filter with a not equal to operator, where the requirement is that the output not match an exact text string. I have tried <> and <>"???" (where ??? is the text string) and neither filter is working.
View 2 Replies
View Related
Mar 27, 2008
I'm using this macro to retrieve data from a worksheet within the same workbook. As you can see, I've set the destination range between row 12 and row 20. The problem is this code clears all text (not other formatting) from row 12 down even farther than the row 800 that is the end of my Origin range. QUE: How do you limit the reach of the ClearContents code?
Origin Name Range Definition
= 'ORDERS 1st QTR 08'!$A$1:$J$800
Sub GetData()
Application. ScreenUpdating = False
Range("A12:J20").ClearContents
Range("Data_Table"). AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Range("M1:M2"), CopyToRange:=Range("A12"), Unique:=False
Application.ScreenUpdating = True
End Sub
View 9 Replies
View Related
Nov 30, 2009
The data to be filtered is in several sheets, and once filtered is to be copied to a destination sheet (in this case "Temp"). The criteria for advanced filter is on an altogether different sheet (in this case "Reports"). The macro is actually simplified for the purpose of the question, and I want to re-use the code several times, hence the use of variable "filterRng". When I run it, I get the subject error at the bolded line in the code below. I'm thinking that the Advanced Filter doesn't like a variable as a range reference, as it runs perfectly well if the commented out line below the problem line is used instead.
Sub Test()
Dim i As Integer
Dim rngData As Range
Dim filterRng As Range
Set filterRng = Sheets("Reports").Range("A121:K124")
Application. ScreenUpdating = False
Application.DisplayAlerts = False
View 4 Replies
View Related
Aug 26, 2006
Trying to pass an array to a procedure to use as criteria in advanced filer.
My code below is raising this error:
Run-time error '1004':
The extract range has a missing or illegal field name
rngData. AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rngCrit, CopyToRange:=rngDest, Unique:=False
Private Sub btnOK_Click()
Dim arrValues()
Dim lngI As Long
Dim lngX As Long
With Me.lstAccounts
If .ListIndex <> -1 Then
For lngI = 0 To .ListCount - 1 ................
View 9 Replies
View Related
Sep 23, 2008
Is there a way to retain a formula when you have a drop down options that generates a date stamp? The problem is, i have this worksheet that has a drop down option on column B and generates the Due Date on column A, once an option is selected on the drop down list. After selecting, the output becomes static, but then overwrites the formula of column A, thus i guess making it static. I've had great help from this board helping me with the formula and the vb code. Is it possible? Here's an example of the formula and the ...
View 9 Replies
View Related
May 14, 2006
I am starting to use formulas and I am constantly amazed at the power of Excel. I am trying to write a spreadsheet and I'm having a problem getting Excel to do what I want; I have 2 column, each cell in Column 1 will have a numeric value changed daily. I want Column 2 to retain the highest value that has been added. i.e. If I type 4 in A1,(for example), on Monday, then B2 will read 4, if I type 5 in A1 the next day, then B2 will change to 5, but if I type a value less than 5 in A1, then I still want B2 to read 5. The value will be input daily for an indefinite period and needs to be user friendly. I can't work out how to achieve this.
View 5 Replies
View Related
Apr 24, 2014
I am creating a worksheet that uses a series of if formulas to determine the correct cell to use in a table outside the printing/viewing area. Something along the lines of "if X, Y, and z happens then use what is in cell AY34". I have the formula working, so I can get it to go pick up what is in the cell I want.
The problem I am having is that there is a heading to the text in cell AY34 that is bold, but the rest of the text in the cell is not bold. Is there any way to drag the formatting along with the data and not just the values?
View 3 Replies
View Related
Sep 24, 2011
I am trying to use an "IF" statement to either apply a formula or retain the last value of the cell, is there a way to accomplish this.
E.g. = IF( A1=B1, "retain last value", D1)
last value = the value of the cell prior either to A1 or B1 being changed.
View 6 Replies
View Related
Jul 16, 2013
I have a spreadsheet for recording property maintenance. All properties are grouped by a city zone in a specific colour, and there is conditional formatting on this. Also drop down lists for properties, contractors etc.
This all worked well, until I needed to start inserting rows. All the conditional formatting and lists didn't replicate on the newly inserted rows.
Also, we need to assign a unique reference number to each row but currently manually inputting them - very inefficient way of doing this as they will inevitably get mixed up and confused as rows are removed.
Spreadsheet.jpg
View 9 Replies
View Related
Feb 12, 2014
I am using the VLOOKUP function in a cell, however, I would like the value returned to also retain the text format from the table (eg colour and bold). I have attached a simple example (to demonstrate the point) where cell B14 should have the word 'French' in bold red.Example.xlsx
View 3 Replies
View Related
Nov 28, 2008
I have a template A that has lines on it, sometimes I want to overlay template B which has other lines on it, however when I past template B on top of A the formats of A are overridden by the formats of template B.
Is there any way of "overlaying" B on top of template A without losing the template A formats?
View 7 Replies
View Related
Jul 20, 2014
I have the following code below. I would like to amend the code to retain the previous entry in the input box and amend this if the need arises
Code:
Sheets("data").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = InputBox("Amend details if different from data in inputbox")
View 2 Replies
View Related
Jan 31, 2007
I have cells that contain number that have dashes
For example
Cell M contains the number 001-1234
Cell N contains the number 1234567 (I have formatted the cell to appear with a dash at the beginning -1234567
Cell O contains the number 891 (I have formatted the cell to appear with a dash at the beginning -891)
I want to combine the three cells and have the number look like this
001-1234-1234567-891
Is there a formula that will do this
I have tried the Concatenate to combine the cells but it just combines the numbers and won't let me format the number as I want it.
View 9 Replies
View Related
Sep 9, 2007
I have created a multiple choice quiz maker that randomizes the questions and responses. This means that the quiz questions/responses must be copied and pasted each time a new quiz is generated. But in doing so, Excel loses formatting (such as super and sub scripting) and some special characters (like pi, alpha, the degree symbol).
Is there a way to get such things to copy properly from cell to cell, sheet to sheet, using Excel?
View 9 Replies
View Related
Feb 1, 2008
Coworker was sent a spreadsheet with a singe column of loan numbers; some start with zeros, some don't. But every single cell ends with a "^". (Shift key and 6)
i.e. 0087459832^
782360134^
View 9 Replies
View Related
Nov 20, 2009
I am in a situation where I have to copy-n-paste text from a webpage into Excel. When I do this, the pasted text keeps the formatting of the webpage. The font is the webpage font. The background color is the background color of the webpage. Etc.
I know that I can paste just the text itself, without any of the formatting, by right-clicking, selecting "Paste Special...", and then selecting "Text" instead of "HTML". I am wondering if there is an option somewhere that will do this automatically when I hit CTRL-V instead of requiring me to pull up the Paste Special dialog box.
View 9 Replies
View Related