VBA Macro To Filter And Sort
Aug 6, 2008
I'm tryin to set up a macro to filter and sort and when I record the macro correctly it does not run properly.
I have detailed info below:
I created a sheet "Met Logbook" which contains all links to the source "Master Logbook". This master logbook has a lot of info added daily and we add info at the top of the sheet (we insert new rows every time at the top for different reasons). So what happens is the master logbook always changes its cells (when inserting new rows at the top, all the cells change row number). So I have just linked all the cells and more that we may be using in the Met logbook. This is why I need to filter and then sort the Met logbook (since there will be so many blanks, unuseful info and in the wrong order). (It will be in the wrong order because the "master logbook" has newer info at the top and I have more than one sheet of info for the master logbook) (so my links in the met logbook are somewhat out of order).
So what I need is to have code to filter column B with:
ã
and column H with "Blanks", then I need to sort column A (rec'd) in descending order (so that newer info will be at the top). I will post my Met Logbook sheet on my second post since its a little large.
View 49 Replies
ADVERTISEMENT
Nov 26, 2008
I would like to ask if it is possible to sort a range of row? What I mean is, if I sort like Row 1, the entire block of row 1 will move as well? Like if i have column A to F, then row 1 of column A to F will move together at the same time.
View 3 Replies
View Related
Feb 11, 2008
I am in the process of making a database more efficient and am running into a problem with sorting data. I currently am trying to use AutoFilter to sort the data. When I want to then narrow the results further using the same column as the critical and there is nothing that matches the critical, I get everything from the entire database that matches that critical rather than what I want to see, which, in this case, would be nothing.
I have attached a sample file. In it, when All AF 1000 is run and then Selected MAC 2000 Wash is run, I want to see no results instead of seeing all MAC 2000 Washes from the original data set. I can do it using IF/THEN but I am looking for a faster way to do it.
View 3 Replies
View Related
Apr 5, 2010
I have a worksheet of 10 Columns and over 5000 rows. The worksheet has the word {Group} in brackets after the file name. When I pasted this worksheet into an old file I have been using for a long time it added the word {Group} to this file also.
I am unable to use sort or filter on this worksheet as they are both grayed out.
View 8 Replies
View Related
Jan 23, 2010
I have two columns of numbers. The first column is numbers of customers seeking specific products. The second column is of total competitors for the products. I am wanting to find a sort or filter that will show me the "sweet spot" where I can "weight" the best products that have greatest seekers but lowest competition.
Here are a few examples of what I am working with:
Product a - People seeking product: 167 / Competitors providing product: 5740
Product b - People seeking product: 111 / Competitors providing product: 133000
Product c - People seeking product: 74 / Competitors providing product: 105000
Product d - People seeking product: 60 / Competitors providing product: 109000
Product e - People seeking product: 33 / Competitors providing product: 22200
(I have many more products than this, this is only a small example)
So what my goal is is to run through all my data and find the most ideal products (the "sweet spot") that have greatest number of seekers/potential customers with the least competition.
Is there a way to sort this? Or do I use a filter of some type. My knowledge of Excel is pretty minimal.
View 9 Replies
View Related
Mar 18, 2007
For some reason I have a worksheet that won't sort stuff by Autofilter any more. I built it as a customer database but for some reason today I just can't get the names to ascend or descend. there is something simple I can check for, I can post an empety sheet if needed but right now I can't really post a list of all my customers info.
View 5 Replies
View Related
Jul 13, 2006
I am trying to perform a function that searches through the first column for any active "A" account and then copies the corresponding rows information into another worksheet. I think I need to use the advanced filter function however I can't seem to figure it out.
View 9 Replies
View Related
Mar 21, 2007
I'm trying to write one macro that filters a set of data based on 2 criteria and then automatically sorts the filtered data by date. The filter works fine but when I then try to write code that handles the automatic sort, I get the following message when I run the macro: "Run-Time Error 1004: the sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank."
I realize it would only take one or two more clicks to sort this data manully after the macro is run, but the lazy person in me is trying to eliminate this step. Does anybody have any suggestions as to why the sort is not working? I parsed basic sorting code, but it hasn't worked. The other part of this that is causing me trouble is that the number of filtered rows will vary, so I'm only needing to sort the visible range.
View 9 Replies
View Related
Dec 1, 2013
In the first picture the Pivot Table is showing the profit of each city in 2010 and 2012. Where I used Sort & Filter Largest to smallest, in order to display the cities with greatest profit.
Prosent.png
But when I switch the values to `% of` year (Previous). I get the change from 2010 to 2012 in percentage. But my PROBLEM is when I want to Sort & Filter from Largest to Smallest, cause I want to show the cities that have had the greatest percentage change from 2010 to 2012. But the I only get the same cities, and when I look at ex. 'Gjovik' is has had a 125 % in change and should be in the top.
So how am I able to Sort & Filter from Largest to Smallest the cities with greatest change in percentage?
View 3 Replies
View Related
Nov 9, 2008
Is there any way to allow autofiltering and sorting even with locked cells within the range to be sorted? I've conditionally locked some cells based on user input, and at the end of my vb code I have allowsorting and allowfiltering. But I want to sort cells that are locked even after that. Does anyone know if that's even possible with VB?
View 4 Replies
View Related
Oct 24, 2011
I have a filter on the Qty column but when I sort Z -A or A - Z it does not work. I have tried formatting as number but no success, I have never seen this before, why the sort wont work? I am using Excel 2010 in Win 7
View 5 Replies
View Related
Apr 4, 2014
We have 2 dynamic ranges (input, output) on different sheets (sample data below).
Sheet1> Input
Dynamic range 5 columns
Sheet 2>Output
Dynamic range 4 columns
- Include only rows IN=1
- Sorted by LEVEL (BIG to SMALL) and BUY (SMALL to BIG)
- Keep duplicates
What formulas should I place on Sheet2 avoiding Pivot tables or VBA?
Sheet1> Input (16 data rows)
A B C D E
Level Buy Sell Firm IN
16620 4.00 null F1 OUT
16610 5.10 0.80 F1 OUT
16600 11.40 6.60 F1 1
16590 24.50 18.60 F1 1
16580 44.90 37.10 F1 1
16570 66.90 59.60 F1 1
16560 84.40 78.70 F1 1
16550 95.00 90.30 F1 1
16540 99.80 95.60 F1 OUT
16530 100.00 98.00 F1 OUT
16611 6.66 0.497 F2 OUT
16600 9.09 1.96 F2 OUT
16589.1 20 12.5 F2 1
16578.2 41.66 33.33 F2 1
16567.3 73.33 65.21 F2 1
16556.4 90.9 84.61 F2 1
16545 98.5 91.66 F2 OUT
Sheet2> output (10 data rows)
A B C D
Level Buy Sell Firm
16600 11.4 6.6 F1
16590 24.5 18.6 F1
16589.1 20 12.5 F2
16580 44.9 37.1 F1
16578.2 41.66 33.33 F2
16570 66.9 59.6 F1
16567.3 73.33 65.21 F2
16560 84.4 78.7 F1
16556.4 90.9 84.61 F2
16550 95 90.3 F1
View 6 Replies
View Related
Apr 14, 2014
I have a cashflow spread sheet on which there are three properties that are currently being renovated and are being rented out. I would like to see ongoing costs for each individual property on the main spread sheet. I can filter and sort by the properties and autosum to get the individual costings of properties, but I would like to be able to see the costings of each property on the main spread sheet once I have stopped filtering.
View 1 Replies
View Related
Jun 6, 2014
Is there any way to filter/sort a workbook by a specific text. (EX. Unit 17) I have a spread sheet with 40,000 plus rows and in 1 column it has descriptions. I am needing the filter to filter out all occurrences of Unit 17 and Unit 16. They will not always say the something happened to them. EX Repair brakes on Unit 17 or maybe repair tires on Unit 17...
View 3 Replies
View Related
May 2, 2014
I just want to filter and sort the data based on names and hours.
Here it goes:
1. Filter Column F.
2. Filter it by: UK & M UK
3. After that, filter Column E in "Ascending order"
4. Count the data that are:
-starts 1:01AM - 7:59AM and display the total count in Sheet2, if there are no data in other specific time, then display a value "0"
For example for UK and M UK:
In Sheet 2, ("F5") = 3 as there are 3 data, G5=1, H5=0 and so on and so forth..
I've attached my file : Filter and Sort.xlsx‎
View 3 Replies
View Related
Sep 9, 2012
I have following data to sort/filter
Sector
Flt no
origin
[Code]...
Is this possible with excel functions?
View 1 Replies
View Related
Sep 27, 2008
I have a spreadsheet with multiple columns. The first column defines a "route", and the next two list "start" and "end" cities for that route. The fourth column lists the length of each route. There are only a limited number of cities, so the same entries appear in both "start" and "end" several times. I would like to use Autofilter to sort the list for every appearance of a given entry in either "start" or "end". Is there a way to make Autofilter sort mutiple columns simultaneously?
I could achieve the desired end result with Advanced Filter, but I want something with the ease-of-use and immediate update/response of Autofilter. Advanced Filter requires explanation (as well as lots of clicking and typing) whereas Autofilter is self-evident. I also want to avoid VBA Macros as they are not well-understood by the users who will use this spreadsheet (and any VBA Macro will require very specific input to work properly.) Is it possible to do what I want? Or is Advanced Filter / VBA the only way to do it?
View 2 Replies
View Related
May 25, 2012
Writing code to do the following:
Save advanced filter settings
Remove filter (or simply set to be 'select all'
Run other code (I have this piece of course)
Put filter back on with same selections chosen as when it was removed
(Need this becuase the code in the middle does not work properly when the data is filtered)
View 1 Replies
View Related
Jun 5, 2013
what I do with excel: I have an excel sheet that has over 18,000 rows in it. Since it would be a nightmare to scroll around to find what I want, I use the Custom Sort and Filter options under Editing>Sort&Filter. So for example, I can omit 17,800 rows using a specific setting so that I can work with a more reasonable 200 rows. Moreover, the 200 rows comes from all over the spreadsheet. Meaning their row numbers are not always consecutive.
Here's the problem: Whenever I try to copy anything from this "edited or filtered" excel sheet, the resulting paste is not an exact copy. Excel perfectly copies the first rows up until the point where the row numbers ceases to be consecutive. So, the copy function messes up somehow when the data being copied comes from a different section of the original 18,000 rows.
In case this isn't clear enough...
Let's say that the original file has rows 1,2,3,4,5,6,7,8,9,10
Once I filter/custom sort, I see rows 1,2,3,8,9,10
When I try to copy/paste 2,3,8,9, excel copies 2,3, but messes up the rest of the 8,9. And I end up with a totally useless copy that's generally shorter than it's supposed to be.
View 6 Replies
View Related
Jun 6, 2014
I have a workbook has a "Summary" worksheet. I would like to be able to do the following:
(1) Sort columns D, G, J, M,... (the number of columns are different each time I run the macro that I have).
(2) create a combo box to be able to the data (that sorted in 1) by month (1,2,..., 12).
see the attached file
View 5 Replies
View Related
Nov 5, 2009
I am looking for a macro to sort my colums in ascending order the range i need sorted is from A7:F107, it will be sorted with the numbers in the A column ie 1 - 107. sometimes different numbers get added and it has to be sorted in number sequence.
If possible i would also like a macro to protect this range after the sort,
View 3 Replies
View Related
Mar 15, 2013
Data manipulation question here: how to dynamically filter and sort a multi-column data set? My end goal is to be able to (1) quickly collapse all columns into one single column, (2) remove all duplicates, and (3) sort the information in ascending order. A reference sheet is attached in case it's useful.
View 5 Replies
View Related
Apr 16, 2013
I am using Excel 2010. I am a novice user.
I have a lot of data to filter / sort. I want to initially to create a filter for a column of data - which has the format similar to hierarchical paths to files. The data is a mix of text/numbers. e.g.
pathA/path_X/path_Y/path_Z/lso0_rxs_reg_254__5_0/d
pathA/path_X/path_Y/path_Z/lso0_rxs_reg_253__5_0/d
pathA/path_123/path_456/data_out_reg_17_0/d
pathA/path_123/path_456/data_out_reg_0_0/d
pathA/path_X/path_Y/path_Z/lso0_rxs_reg_255__5_0/d
[Code] .........
Doing an alphabetical sort of this date would return the following order. As you can see while each strings in unique - there are many instances where they are simialr - if you ignore the unique numeric values at the end of the string.
pathA/path_123/path_456/data_out_reg_0_0/d
pathA/path_123/path_456/data_out_reg_17_0/d
pathA/path_123/path_456/data_out_reg_4_0/d
pathA/path_X/path_Y/path_Z/lso0_rxs_reg_230__6_0/d
[Code] ......
So what I want to do is to create a filter for the strings - but ignoring the numeric bits at the end i.e.
reg_[0-9]+_+[0-9]+/d
The strings are obviiously of varying length and the number of hierarchical paths is different, so I can't split string on "/".
Similarly folder paths names can contain "_" so can't split string on this either.
As I don't know how many "/" or "-" instances there will be in the string I don't believe I can use the find function. Also as the amount of number will be different i don't think I can use =right(a1,X) either.
I may be able to search for the pattern above - as this is probabay unique - so maybe it's something like the following pseudo code:
Function GetString(txt As String) As String
With CreateObject("VBScript.RegExp")
.Pattern = "reg_d+(_)+d+//d"
GetString = .execute(txt)(0)
End With
End Function
If I do require VBA code - how do I then use this for creating a column filter? Or will I have to extract the filtered data first from the column (and its associated row data) into another worksheet to use?
Once I have the filter in place I want to create tables using the filtered data - so for example each column value above has a lot of associated data values in each row e.g
26 pathA/path_123/path_456/data_out_reg_0_0/d
32 pathA/path_123/path_456/data_out_reg_17_0/d
8 pathA/path_123/path_456/data_out_reg_4_0/d
So my table would show the name "data_out_reg" and the range of values 8-32
View 1 Replies
View Related
Jul 21, 2007
I am making a spreadsheet that sorts and pastes, but I need to know if I can add a code to the Sort and Paste Macro that will open the second spread sheet needed without just already having it open and using the
Windows("estimate sheet one.xls").Activate
View 2 Replies
View Related
Feb 25, 2009
I need is to run a macro which does the following:
Autofilter is on, so on column AR filter to results that show '1', then on column H for all results there are 6 max but some dont show when '1' is selected as data may not be present.
So once I have filtered down AR and then filtered down H, I need a sum on AN, and AO for JUST those results!
Now I can do all this manually and have a quick mock code but this needs to be done sooner rather than later so im going to cont doing it manually if anyone can help with the code it will speed things up for me tho, thanks!
Sub SpeedUp()
' Location is in H, Quartile is in AR
' I to AM is irrelevant
' SUM of AN
' SUM of AO
Dim Arr As Variant
Arr = Array("F1", "F2", "F3", "F4")
For i = 1 To 4
So basically loop thru, loop thru, change the filtering, subtotal on the new filters copy to a new sheet, or even hold all values in a table or array till the end and i will manually paste
View 9 Replies
View Related
May 10, 2007
With guidance from this board in the past, I was directed to a macro that sorted information on a sheet (using values in column 1), opening a new sheet named by the sort title then copy/pasting all the relevant entries
The only restriction for this macro is the fact it is set to only sort information on sheet named Sheet1
I wanted to change this to an InputBox so the user can tell the macro which sheet to sort
View 9 Replies
View Related
Sep 21, 2008
I've got up to 150000 rows in excel (2007) and i need to sort the data into 2 sheets.
Sheet1 contains all the data. Sample:
1000999999027FRESH PASTA FETTUCINE WITH TOM102002P N0809100000035000000012810000000+0000000+ 0000000000000000+0203001896409
2000999999027020300189640900000000000005740200070063
As you can see, the first row starts with 1000 and second with 2000. That would be the criteria. All other rows goes exactly the same.
I need macro that copies all the rows starting with 1000 onto sheet2 and all the rows starting with 2000 onto sheet3.
Filtering and copy/paste won't help, because the list is toooooo big. Thatswhy only hope is to find macro that loops threw the list.
View 14 Replies
View Related
Nov 8, 2008
I am now trying to write a macro which is a little over my head and was hoping some one may have some idea how to do it or have some code that is similiar and I can try to customise it myself. So here goes.
Basically all that happens is I paste data into a work book that always has two columns. The first column is a list of names and the second column is a list of numbers. I need to sort that information automaitcally every time it is pasted into the work sheet as follows.
1) Once any information is pasted to sheet 1 run macro automatically with no user interaction
2) All numbers must be rounded up or down first before sorting. If it is say 2.4 then it would become 2 and it it was 2.6 it would become 3.
3) Then move the numbers only from a specified column from sheet1 to sheet 2 and split them up into seperate columns based on the following results.
a) 0 - 3 gets moved to column B
b) 4 -7 get moved to column C
c) 8 - 10 gets moved to column d
4) Delete both columns from sheet1 after this is run so the user can re paste new information
5) If a user does this again then do the same but move into a new set of columns e f g and so on until the work book ends.
View 13 Replies
View Related
Feb 3, 2009
I have a sort function in one of my macro. Sometimes it works, sometimes it does not. I can't figure out why. I am trying to sort columns A-F and each column has a header.
View 2 Replies
View Related
Feb 16, 2010
I have a data set that id like to sort via macro. The first two fields are not relevant to the sorting proces.(Column A & B ). Column C contains totals some are zero, some are greater than zero and some are less than.zero. I have a macro which I use for many reports that sorts based on Autofilter but I dont know how to change it so that I can use less than, greater than and = to 0. Below is my attempt which didnt work.
View 9 Replies
View Related