Sort Area Around Active Cell By Two Columns
I have various lists of data (using Data > List > Create List...) that do not always have the first cell in the list in column A. I have spent quite a bit of time searching the internet to try and find a macro that will work the same as... Data > Sort > Sort By: Col xx > Then by: Col xy.
Dave supplied me with a macro that will sort a range by the first column:
Sub SortThis()
With ActiveCell. CurrentRegion
.Sort Key1:=. Cells(1, 1), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub
I have recorded macro that does the same and looked at the code but this uses Range and specifies the cells to be sorted. I have not been able to work out how to modify the code Dave posted to do a minor sort by the second column. I am after a macro that will determine the range (could be a varying number of columns and rows in different places). For however many columns there may be the macro will sort the full width and height by the first column and then the second column, with all the data within a particular row not being split.
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Sort By Active Cell Column
I am trying to perform a sort based on the ActiveCell.Column I thought my code would exclude the hearer rows, but presently it moves the header rows beneath the data I tried Header:=xlGuess as well as Header:=xlNo Same result What am I doing wrong? Thanks -marc Private Sub comp_mySort() Selection.Sort Key1:= Cells(1, ActiveCell.Column), _ Order1:=xlAscending, Header:=xlNo, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub
View Replies!
View Related
Active Area
I have the following macro that works fine. But, I would like it to stop when it gets to the bottom of the active area. Sub Insert_for_SQs() Do Selection.EntireRow.Insert ActiveCell.Offset(6, 0).EntireRow.Activate Selection.EntireRow.Insert ActiveCell.Offset(12, 0).EntireRow.Activate Loop End Sub
View Replies!
View Related
Hide Columns Starting From Active Cell
Continuing with a large Macro I am trying to peice together, I have reached a hurdle where I need to hide all columns to the left of the ActiveCell (which varies week to week) back to column B. I have the following code which selects the correct number of cells to the left of the active cell but doesn't highlight the whole columns - just 3 cells for each column (very odd) ActiveCell.Offset(0, -1).Range("A1").Select Range(Selection, "B" & Selection.Column).Select I'm sure it must be something to do with the Selection.Column part as when I write Selection.Row it just does 1 cell for each column (as to be expected) I should mention I already have the coding to hide the columns, just need a way to highlight the relevant ones.
View Replies!
View Related
Set Print Area Based On Sort
I have a worksheet which contains data for 6 different groups. I have a sort macro already that sorts them into groups (group 1, group 2, etc.) What I want to do know is set the Print Area so I can just print each group individually with a button("print group 1", etc.) The worksheet is set up as follows: Columns B-H are the data I want to have printed. The number of rows is different for each group. I want to set the Print Area based on Column H. So, if H=1, set the Print Area for Columns B-H and all rows that have H=1. This seems like it should be simple enough, but I haven't quite been able to put the pieces together yet.
View Replies!
View Related
Range X Rows & X Columns From Active Cell
Im writing a macro and have a cell activated (using ActiveCell). If I want to select this cell (the activated one - i.e., k3) along with the 2 cells next to it (i.e., l3, and m3), how would i go about doing that? I'm wanting to shift 3 cells downward and I know how to shift them down, but dont know how to select the cells i want.
View Replies!
View Related
Macro To Print Active Area Excluding Cells With Forumula That Doesn't Return Value
Trying to put together a macro that looks down active sheet for all cells that contain a value, sets a print area and then prints ! Is this possible? FYG, I have a column that run from 3 - 2000, which contains a formula, which may produce a value depending on corresponding cells. I used this code from a post on a similar topic, but excel is complaining code in bold Private Sub Print_Area_Click() Dim lastCell As Range Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 0) Do Until Application.Count(lastCell.EntireRow) 0 Set lastCell = lastCell.Offset(-1, 0) Loop ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address End Sub
View Replies!
View Related
Sort Data On All Worksheets Active And Other
It sorts the ActiveSheet, but none of the other sheets and there's no runtime error. I am using this on a test workbook with the same data in 5 worksheets. What's wrong with this code? Sub SortSheets() Dim ws As Worksheet For Each ws In Worksheets Cells.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _ xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Next ws End Sub This looping structure works for PageSetUp, but not this Sort.
View Replies!
View Related
Sort Range On Non Active Sheet
I'm trying to sort data on sheet1 and sheet2. I'm running all macros from sheet one and I need it to stay active all of the time. I'm using the following code to sort sheet2. When I sort the column on sheet2 with the code, I can not get back to sheet one without an error. Worksheets("Sheet2").Activate Columns("a:a").Select Selection.sort Key1:= Range("a1"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal I've tried Worksheets("Sheet1").Activate Columns("a:a").Select..............
View Replies!
View Related
Sort Horizontally. Sort Across Columns
I am trying to sort a long range of text that is placed horizontally in a spreadsheet. I can do it vertically with the sort function in Excel but it does not seem to work for text that is placed horizontally. Example is as below: Inventory Accounts Human Resources
View Replies!
View Related
Sort Multiple Columns, With Blanks, And Move All Columns Into One
I found this code on Ozgrid to sort all columns of a worksheet that were continuous with no gaps or spaces that works well: Sub CopyToA() Do While ActiveCell <> "" Range(ActiveCell, ActiveCell.End(xlDown)).Cut Destination:=Range("a65535").End(xlUp).Offset(1, 0) ActiveCell.Offset(0, 1).Select Loop End Sub However, I've tried to manipulate the code myself to 1) find all columns that aren't empty then 2) sort each column individually (WITHOUT expanding the sort to other columns) and 3) combining all the numbers into one seperate column. There are many posts concerning sorting but not one that addressed this particular situation.
View Replies!
View Related
How Do You Sort Columns So That They Match Up With Other Columns With Like Data
I have two columns one is web addresses and the other is email addresses but the rows do not line up. I was hoping that since the second half of the email address matches the web address I could somehow sort them so that the email address column and web address column match up. Here is an example but keep in mind that this list is about 9k long and this is just a sampling so you may not see any in this example that match. Also I may have more than one email address per website.
View Replies!
View Related
Sort All Columns Except For Few
I am using a formula but when it sorts with the data in the adjacent cells it does not update the reference cells properly. For example here is the =SUMPRODUCT(($F$12:$WWX$12>=C1)*1,($F$12:$WWX$12<=E1)*1,ABS($F$13:$ZZ$13)) This code is located on row 13, when I do a sort function with all the data, this code is then moved to row 30, that is fine but the code changes in the following way: =SUMPRODUCT(($F$12:$WWX$12>=C18)*1,($F$12:$WWX$12<=E18)*1,ABS($F$13:$ZZ$13)) C1 & E1 should not have changed at all, F13 & ZZ13 should have changed to F30 & ZZ30. I am not sure if there is a way to fix the formula so it updates correctly, or these cells can stay in the same place as long as everything else sorts. Is is possible to sort all columns except a few?
View Replies!
View Related
Sort Columns A B C D And E
I am trying to get columns A:E on Sheet1 converted into columns A:H on Sheet2. I attached the workbook with the macro so you can see what I am talking about. I posted the same macro in the workbook below. It comes close to what I am trying to do but it only sorts based on Column E. I would like to include Columns A, B, C, and D in the sort instead of just Column E so the display will look like Sheet2.
View Replies!
View Related
Sort A To G And S Columns
r = Range("c65536").End(xlUp).Row Range("a5:G" & r).Select Selection.Sort Key1:=Range("G5"), Order1:=xlAscending, Key2:=Range("F5") _ , Order2:=xlAscending, Key3:=Range("C5"), Order3:=xlAscending, Header:= _ xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _ xlSortNormal Rows("4:" & r).Select For i = 5 To r Rows(i).Select If i Mod 2 = 0 Then Selection.Interior.ColorIndex = xlNone Else Selection.Interior.ColorIndex = 36 End If Next Range("j5").Select Application.Calculation = xlCalculationAutomat this sorts range from A to G and set color to each second row how can I include S column in this range I mean that cells in column S are moved with cells from columns A to G.
View Replies!
View Related
Match And Sort By Two Columns
Column A has customer name, columns B,C,D has corresponding sales data for that month. Column E is blank. Column F has has customer name. Column G,H,I has the same corresponding sales data for the next month. Although Column A and F both have customer names, there are many changes month over month with the addition and deletion of certain customers so the rows do not match up exactly. Is there a quick way to have the rows match up according to customer names in column A and F and then sort them alpabetically? Currently my list looks like this: Jan Feb A A B C D D F E H F L G M H I would like it to look like this: Jan Feb A A B C D D E F F G H H L M
View Replies!
View Related
Sort Columns By A Button
I have a code with perfectly sorts Excel rows when you click a button: Private Sub CommandButton1_Click() Worksheets("Sheet1").Range("C1:S70").Select Selection.Sort Key1:=ActiveCell, Order1:=xlAscending End Sub but if i like to sort the columns by Row 1 how i can do it?
View Replies!
View Related
Sort Two Columns Simultaneously
I'm trying to sort selected rows by two columns, but simultaneously instead of sorting by "Column A and THEN Column B". In my case, this is numerical data where there is ONLY data in one column or the other, never both. For example: 5 _ 10 _ _ 1 _ 6 _ 4 Should sort to: _ 1 _ 4 5 _ _ 6 10 _
View Replies!
View Related
2 Columns Table Without Using SORT
I have some table with 3 columns: Name, Team, Players with the same name I want to get to a 2 columns table without using "SORT" or something like that... using only formulas. Maybe I wasn't so clear so I added a file with my problem.
View Replies!
View Related
VBA: Sort On Two Columns
I have the necessity to execute a macro for sorting a list of data on two columns. More exactly, let's suppose to have this situation: A 10/2/2008 FFFF GGGG HHH B 01/3/2008 PPPP LLLLL NNNN B 12/4/2008 XXXX JJJJJ PPPP B 08/1/2008 HHHH SSSS IIIII C 15/10/2008 AAA BBBB CCC I need this sort: A 10/2/2008 FFFF GGGG HHH B 08/1/2008 HHHH SSSS IIIII B 01/3/2008 PPPP LLLLL NNNN B 12/4/2008 XXXX JJJJJ PPPP C 15/10/2008 AAA BBBB CCC
View Replies!
View Related
Sort Like Numbers In 2 Different Columns
I have 3 columns; A:Name, B:Debit & C:Credit. There are multiple row (approx 15,000) where I have a customer name and then a debit at one date, and a credit at another date. There is a debit to match every credit. I would like to some how sort the sheet so that I can make sure each credit matched the debit. That way I can find what debit's don't match the credits. This is an example of how this looks. http://i303.photobucket.com/albums/n...kejoe/sort.jpg. I would like to sort it like the example on the far right (see attached picture)
View Replies!
View Related
Auto-Sort Columns
I am trying to create a VBA macro that autosorts a selection of columns by column A. I currently have the below already written which gives the desired effect. I was just wondering if there was a way i could have this script constantly running on the sheet so it is always sorted correctly without me having to click Run Macro everytime. Sub Macro1() Columns("A:F").Select Selection.Sort Key1:= Range("A1"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub
View Replies!
View Related
Graph The Following Data In An Area Chart With Line Charts Superimposed On The Area Chart
I am trying to graph the following data in an area chart with line charts superimposed on the area chart. I have a lot of data (and a lot going on) so I'm trying to figure out the best way to show this in excel from a functional standpoing (i can't get this to work in excel!!) to also an asthetic standpoint (dont want it to look terrible or illegible). This is what I'm trying to chart: 1) Weather data (temperature) by region: So one region, would be: Northwest I would like the "area" (so a shaded region) to be the min/max of the temperature data for each month. 2) I would like to show the temperature for each year as a line graph on the chart - so you can see if a year falls in or out of the shaded region. 3) I would like to show a company's sales increases across the same months per year as separate line charts. I may choose to just show the biggest outlier year in the end... or to show 2006 (the latest data). What I am trying to convery with the chart is that the company's sales is or is not tied to weather deviations. I have attached an excel file with the data. I haven't been able to use the area chart or get a two axis chart to work or get it to look even remotely professional.
View Replies!
View Related
Sort Records That Are 3 Lines By 18 Columns
I have data records that are 3 rows long by 18 columns (A thru R) wide. People's 1st names only exists in the 1st row, 2nd column (B) of each record. The 1st record starts on row 5. I need a VBA procedure that when run, it will sort the data alphabetically by the 1st row, 2nd column (B) of each data record. The 3 line data records looks like this starting on row 5: ________A__|_____B___|____C____|___D___|___E___|___F___|___G___|___H___etc 1st row _18_|_John____|_730-6853_, etc 2nd row ____|_Doe____|_238-4835_, etc 3rd row_____|_Sales___|_328-4893_, etc 1st row _32_|_Jack____|_684-3812_, etc 2nd row ____|_Jones___|_232-4954_, etc 3rd row_____|_MFG____|_238-5355_, etc 1st row _18_|_Jimmy___|_485-2294_, etc 2nd row ____|_Smith___|_223-9110_, etc 3rd row_____|_Maint___|_368-6381_, etc If only above 3 records exists, when sorted Jack's record starts on row 3, Jimmy's record starts on row 6, John's record starts on row 9, etc We can have as many as 15 records (3 lines long) that goes thru row 49.
View Replies!
View Related
Sort Data Over Multiple Columns
I'm trying to figure out a way ( excel 2000) how to sort data over a range of columns. Attached is a sheet. So what I am looking for is this: Bottom 10 for target 1, target 2, target 3. I can sort them indervidually, but is there a way to sort the all? Or would I need a agent column for each target to sort? Or maybe there is a way to sort the data so it would work out that if they are in the bottom 10 of lets say 2 of the targets but not all 3 they would still show in the bottom 10?
View Replies!
View Related
Automatically Sort Columns Simultaneously
there are two colums, one for product name (unique names) and other one is for their prices (may be same for more then one product). I want to arrange these columns by the their price vlaues in assesnding/desending order and to have their unique corresponding product names in respective columns. Provide me any solution, probably using any excel formulas. presently i have tried this using Large and Vlookup funstions...but it fails.. when there are same price is available for two product names, then it takes only first one. I WANT TO GET THIS DONE AUTOMATICALLY, AS THIS IS TO BE POPULATED ON SOME OTHER SHEET AS A PARETO. waiting for your vlauable responces ASAP.
View Replies!
View Related
Auto Sort All Columns Independently
I am looking for some help with a spreadsheet I am working on, the purpose of this sheet is to record case numbers that I am working on. This spreadsheet will have new information added to it regularly and the cases may not be in a sequential order. What I have found is a code that will sort a column of case numbers into an ascending order upon opening the file. What I would like to be able to do is apply the same rule to all columns on that sheet. I have included the current spreadsheet to let you see how far I got.
View Replies!
View Related
Find Cell And Mark Area In Relation To The Cell
I'm trying to make a macro, which search for a cell value of "Year". And from that cell, I want to make a range selection down to the first empty cell in row B or the first cell value with "Contracts of difference". See the attached document I want to mark row 50 to row 55, and Column A to K. However as this range is in different rows each time, I need to make the selection dynamic. And I belive the heading "Year" is the best reference point.
View Replies!
View Related
Sort Columns With Multiple Values In Cells
My columns are labeled A B C D etc... If the product I am creating the table for falls into one of those categories I place a 1 in the cell. For instance, ProductA falls into the A and B categories, so column A will get a 1 and column B will get a 1. This is so I can sort all of category A's Products etc... I am looking for a formula to put in a column that would Say what categories ProductA falls into. ie Since ProductA falls into the A and B catergories but not the C and D catergories, This final column would say something like AB, or A,B or something. Alternatively, I could make a single column entiltled 'categories' and put something like 'A B' in ProductA's column. In this case I would need a way to sort all A's or sort all B's and not just sort all 'A B'
View Replies!
View Related
Possible To Sort Hoizontally With Multiple Columns Under One Header
In row 1 I want to have the names of servers, so we would have A C D E Under each of those I want to have 4 other columns, so A would have on row 2 Start, End, Data, Time, or something like that. Then B would have under it Start, End, Data, Time And so on for C D ... I would then want to sort it by the top level row, so if I had to insert B at the end I could sort it so it would be A B C D E with all of the Start End Data and Time for the server to be moved along with it's master header. I tried setting this up but then I went to sort it told me it could only sort if the columns were the same size, so having a merged top level A with four things under it did not work.
View Replies!
View Related
Sort Repetitive Data From Rows To Columns
I have a column of repetitive data: BLANK CELL NAME ADDRESS CITY, STATE ZIP BLANK CELL I would like to be able to resort the dats so that each line becomes a column BLANK CELL NAME ADDRESS CITY, STATE ZIP BLANK CELL I know I can do it 3 cells/rows at a time using the paste special and transpose command but I have a 1000 names and addresses. How do I do it in one operation instead of a thousand?
View Replies!
View Related
Special Row Sort Of Multiple Columns
I have a Name in Column A I have a Number total(using a formula) in Column B Each week I am copying from another source Names and Numbers, let's say in Column C and D. I want to match the names in A with the Names in C so they are in the same row. The number in Column D needs to go with name from Column C. Right now I am having to highlight the name and number in Column C & D and then drag it down to the row with the exact name in Column A. If there is a new name it adds it at the bottom of Column A and C.
View Replies!
View Related
Auto Sort Columns On Workbook Open
I have a worksheet with 10 columns, and an ever number of growing rows. What I would like to do is to Sort Column 'B', along with all the other respective data in the other columns, each time the spreadsheet opens. I would prefer to use VBA or some other auto-launching event.
View Replies!
View Related
Text Box Or Cell Area Updating
I have two sheets in my workbook. One named singledump and the other individualfileselect. Within single dump i have daily data loaded with certain cells containing comments added for that day of the week. E.g. Tuesday 3000 Below average clearances, we will look in to this further throughout the week. What i would like to do is have either a text box area of just simply one cell updating with a the first comment from the week and to then have two buttons back and forward allowing the user to click and the cells will update for the next comment that week or go back to the comment before. How would i be best going about this? To be honest i would prefer to keep away from text boxes and would be happy with just the two buttons scrolling through specified ranges to update a cell on individualfileselect sheet.
View Replies!
View Related
Filter & Sort Multiple Columns With Single Criteria
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 Replies!
View Related
Found In A Range, And Then Sort Their Corresponding Price Values From Highest To Lowest In Columns A And B
I'd like to have a list printed of all the "qualifying people" found in a range, and then sort their corresponding price values from highest to lowest in Columns A and B. EXAMPLE: RANGE: D3:D20 - Numerical RANGE: E3:E20 - Text (names) RANGE: F3:F20 - $$$ I'd like to search column D for any values of 2 or higher. When it finds a 2 or higher, I want it to find the corresponding name in the SAME ROW in column E, and of course the corresponding price in the SAME ROW in column F. Then I would like only those qualifying people "with value of 2 or higher" to be listed in order from highest price to lowest price in Column A, and B. COLUMNS D--------E-----------F--- 0-----Mike Bob-----$52.65 1-----Dave Jon-----$42.50 2-----Jane Doe-----$37.65 0-----Gary Lon-----$25.50 0-----Joey Saw----$35.65 2-----Mike Jon-----$35.65 1-----Kate Low-----$38.68 2-----John Doe-----$40.00................
View Replies!
View Related
Delete Columns, Increment Alphanumeric Text, Insert Rows & Sort
I am having to write a vba code for a survey data captured code online. I am attaching the code and the vba module that is suupose to do following things 2) dELETES THE LAST 3 COLUMNS 3) Initial 6 letters from each cell (Q0001=) UPTO (Q00011=) 4)Inserts new row at top from Q1 TO Q11 5) Sorts data on Q6 (Faculty/Staff) Before all this the i need to insert blank cells for questions that have not been answered and shift the cells right (condition 1) ....
View Replies!
View Related
Copy/Special Paste Data Within A Range To Next Empty Cell Then Mark The Copied Area
I'm trying to find a macro that will copy data from the areas of B120:E179 and I120:K179 for example (linked to another worksheet within the workbook) and special paste (Values Only and skipping blank cells) it to the next available open cell up top where basic data entry will be taking place B10:E29 and I10:K29. I need it to only copy/paste the rows with data (skipping all cells/rows with no data) and once it is finished coping I will need it to place an "X" in column M next to the row that it copied data from. I would also need it to reference the data in each row from B to E and if there is an entry say on B14 to E14 that matches it but if I10 to E29 are blank then paste that information on row 14. If it does not match or if those columns are full then paste on next available line. I hope I'm making sense here. This is for a vehicle tracking log between checkpoints. Each driver and info will be listed on each row. Columns B through E will contain information for each driver: name, badge, #passengers, and vehicle #. The log lists location, time, and destination for outgoing travelers in columns F to H. Incoming info is listed on Columns I to K............
View Replies!
View Related
Find Method To Search For The Active And Non Active Values
I have a range of amounts in Sheet 1 from F7:Q13 and im using the find method to search for the active and non active values in the cell. Which means that if there's a value in the cell it will transfer the value in Sheet 2, if nothing is found in the cell the cells in Sheet 2 will return as nothing or null. I think the problem lies on the FindWhat variable. Im getting a compiled error which im not sure what is it. I've attached the spreadsheet so you get a better idea of the problem that i encountered.
View Replies!
View Related
Identify Active Cell And Use The Column To Add Formula To Another Cell
I have a range of unlocked cells (B5:S10) that users enter data in. This sum of this data is then charted. The formula (sum) in a cell equals zero even when there is no data entered by the user. This zero is then charted. I need to be able to plot the zeros if the user enters zeros but not plot the zero if the cells are blank. What I was attempting to do is to use the worksheet change event to add the formulas to a cell so that the chart does not plot the value until something was added. In my change event I need to know that a cell in the range (B5:S10) was changed and that if it was D7 (for example) that I need a formula enterd in D11 [=SUM(D5:D10)]. If it was I5 then the formula would have to go in I11 [=SUM(I5:I10)].
View Replies!
View Related
|