I am trying sort a bunch of different ranges. So I am trying to use the same sort code but run an array of ranges through. This code is for only two ranges
CA3:CD200 and CF3:CI200. I want to pass the ranges as variables through the sort code but I cannot get it to work.
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.
Excel file. The file has two tabs: 'Input' and 'Master'. The 'Input' tab is for users to input any new records, and the 'Master' tab is to retrieve data from the 'Input' tab. Given that some users may want to insert a row in between (rather than add at the bottom).
I used arrays in the 'Master' tab such as:
={IF(ISERROR(1/Input!E2:E250),"",Input!E2:E250)}
Now there came the problem: in the 'Master' tab, the data cannot be sorted when the arrays are used. Otherwise, there is a warning message: You cannot change part of an array.
On from a solution I am using in the sheet which uses very well an Array Formula.
In the attached book I have a sheet with a bunch of tables called Site Table. In the sheet called Working Sheet I want to get the text Site Names and list them in Column A. Sorted would be nice not required but I can't think of way to avoid blanck rows without a manual sort. I tried many versions of Find without a solution as well.
1. The following is the VBA version of what i've been using:
Range("A1:J1000").Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:= _ Range("E2"), Order2:=xlAscending, Key3:=Range("F2"), Order3:=xlDescending _ , Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _ xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _ DataOption3:=xlSortNormal now arrays are bigger than 1000 rows>> even bigger than 65536.
Such an array is stored in "arrBIG" and dimed as (1 to 10, 1 to 100000). The goal is to sort it by the 4'th, then 5th then 6th values in the first dimension - the one that is 1 to 10 - i call this the column.
I have a string (PreString) that gets its values from a procedure call (PreResult). The string consists of 4 values for each loop which I then split into the y array.
I then want to transpose the array to the worksheet for sorting.
I don't really get the transpose to work as I want to. I want every 4:th y to be printed on a new row (x). I don't really know how to use the Ubound function to get it right.
Should I make a 2 dimensional array instead ? If so, how is that made ?
Dim x As Integer, z As Integer Dim var_Status As Integer Dim var_Week As String Dim var_HoursPerWeek As Integer Dim PreString As String
i = var_StartWeekNr j = var_RangeNumberOfWeeks z = 0 x = 0 var_Status = 0 var_Week = "" var_HoursPerWeek = 0 PreString = ""
I have a string that I need to sort. Below code works beautifully but doesn't sort numbers, any advice to get this to sort numbers as well?
Function Alphabetize(ByVal sText As String) As String Dim sWords() As String, sTemp As String Dim i As Long, j As Long, n As Long
'-- clean up text For i = 1 To Len(sText) Select Case Mid$(sText, i, 1) Case " ", "a" To "z", "A" To "Z" Case Else: Mid$(sText, i, 1) = " " End Select Next '-- remove leading and trailing spaces....................
I have a dynamic number of rows each with three colums of values. These varaibles I want to fill an array with but I don't know how.
Now I've just "concated" these three variables into a string and then I intend to split the string into rows by the third comma. (see below)
I think it's easier though to use an array and I really appreciate some assistance. Please tell me also the best way to sort the array. It will be sorted by var_Status which is an integer. (sort order: max positive to max minimum)
Im looking for an algorithm to sort an array of data, deleting multiple values whithin the array and shifting the values down the array to leave no gaps. the crude set of loops i am currently using is:
For f = 0 To 100 For g = f + 1 To 100 If LineArray(g) = LineArray(f) Then LineArray(g) = "" Next g Next f
which does work and serves my purpose but is messy as it leaves blank gaps in the array.
I have been trying to take a variant array that has 6 columns, output it to a new worksheet (although I would prefer to just sort the array but can't get that working - how I can do this please feel free), sort the worksheet by 2 different columns, and then move these values back into the original array. I think I have the dumping and sorting down but I can't figure out the putting back into the array part. Here is the code I have thus far. varRecords is the array I am dumping to the new worksheet.
How can I sort an array of data based on the selection from a drop-down menu? And can it be 'secondary' sorted with the result from a second drop-down (ascending or descending is unimportant)?
In the attached example file, I have two tabs: options and sets. The options tab is to be populated from a form. The sets tab is to draw data from the options tab to create teaching sets. I have managed to create an array formula that does this for me, but what I would like it to do is sort my resulting list alphabetically. For reasons that I won't go into, I need the data on the sets tab to remain in three columns: First Name, Surname and Form.
This is the array formula I am using at the moment: AliGW - Example.xlsx
I have two lists in different columns, which are defined ranges. I want to extract them to a unique list with an array formula and at the same time sort albafetically, without duplicates, like this:
List1 List2
Final List
Audi Ford
[Code] ....
So far, I have this formula which is working in what concerns removing duplicates and exctract a unique list. But it is not ordering alfabeticaly.
I was just recently forced to create my first UDF and after how well it worked I now am very interested in learning more. I am trying to create a function to sort a range by the values in a specific column and return the range. I know this should be really simple but for some reason my code dies whenever it gets to my inner-most loop. I need to use this in a larger function but for now this is my only question. I did find that Excel 2007 has built in Functions for this but my company still uses 2003.
My Public Function SortRange(rngToSort As Range, valCol As Integer) Dim Swapper As Variant Dim i As Integer, _ j As Integer, _ k As Integer
For i = 1 To rngToSort.Rows.Count For j = 1 To rngToSort.Rows.Count - i If rngToSort(j + 1, valCol) < rngToSort(j, valCol) Then For k = 1 To rngToSort.Columns.Count Swapper = rngToSort(j, k) rngToSort(j, k) = rngToSort(j + 1, k) rngToSort(j + 1, k) = Swapper Next k End If Next j Next i SortRange = rngToSort End Function
I would like it to sort for me and I can't seem to get that going. The sort order should be by C ascending, then by B ascending and by d ascending. I am adding this to a macro that is already running. The beginning of the macro copies the sheet and renames it based on myinput.
HTML Dim LstRow As Long Dim Rng As Range LstRow = Cells(Rows.Count, "A").End(xlUp).Row - 1 Set Rng = Range("A2:m" & LstRow) Rng.Select
i have a large sheet that was set up starting at cell A3
A3:P19 is one week of data A20:P38 is the next week of data
Each week contains 17 rows.
What i am trying to get is something that will Name each week, starting with the first week of data A3:P19 "1" the next 17 rows, a to p is named 2 the next 17 rows, named 3
etc etc.
Then i want to sort by range, in decending order. ( I hope this is possible) is this doable? it will save alot of time if it is.
I have the following code for a button on a form which is supposed to add the text entered into textbox1 of the form to the bottom of a range of cells and then sort that range of cells in 'A-Z'.
I am trying to write a macro to sort a range of data by another column. Here's the code that I already have :-
Code: Public Sub sort_data(sort_range As Range, key_range As Range) ' MsgBox sort_range.Address ' MsgBox key_range.Address sort_range.Sort Key1:=key_range, Order1:=xlAscending, Header:=xlYes End Sub
However I get a run time error 1004 stating that the sort reference is not valid.
I have a spreadsheet that I am tryng to sort. I am sorting a range of cells. I get my list sorted how I want but then I want to go one step further which is why I am seeking assistance. After my initial sort I want to select just a few specific cells and resort only them.
I am identifying the cells I want to sort by placing "zzzSort" in column V (V267 to V516) ("zzzSort" is placed in the desired cells automatically).
Is there a VBA code that I can place after my original sort code that would select the rows with "zzzSort" in Column V and then run only those ones through anouther sort.
I know that I could just click sort, decending, "points" etc but I figure there must be a way of it auto updating.....
Please see the attached file - I have attempted doing it with Ranking Formula but forgot that it would just give me error messages when two have the same points so I got rid of that.
Have tried doing it with other formula found on this website and others, however I appear to be stuck. I might be doing it wrong but as I'm not manually putting in the "points", they are being worked out with =( SUMPRODUCT((H4:H16={"W","D","L"})*({3,1,0}))+58) for example, it does not move their position.
What I would like it to do:
1. People select from drop down list whether they think the team will W, D, L 2. The Table to the right should automatically change the points dependant on the result 3. The Teams position should change automatically in line with their new points total.
Sub Sort_Labour_Dates() With Range("A10:Z18") .Sort Key1:=Range("A10:A18"), Order1:=xlAscending, Header:=xlNo End With End Sub
This works perfect but I will be inserting rows between A10 and A18. So when it comes to sorting out the range with more rows it will not sort all the data.
But I do not want to be sorting the whole column as I have seperate data below hence why I will be inserting rows between A10 and A18.
I have it a workbook with 7 worksheets. 6 out of the seven have unique data sets and the seventh one totals them all up. Now I have sorting macros in each of the 6 unique worksheets but unless they are returned to the original sort order (ie: by persons last name: before changing to the next worksheet the totaling will be incorrect as the data is not sorted accross the entire workbook. The reason I sort while inside the worksheet is plainly for printing purposes, then I want to reset the sorting to Last Name column. Anyway I tried to add a macro to sort the data on worksheet_deactivate but instead of sorting the data on the sheet that the user is leaving it does the sorting on the sheet they click to goto. Any ideas? This is similar to another post Sheet Event Code Not Firing:
I've tried putting this code in each sheet individually and the ThisWorkbook / Workbook section as a Private Sub with no avail and the macro I'm trying to run is located in Module1 and is named "data_b"
I have a Ranking tab that has the persons name, weeks, months that subtotal into 2 columns, MTD and YTD. I have set up with 2 Macros to sort based on two columns based on their selection of MTD or YTD.
What I did not take into consideration is if a person was added at the bottom of the list.
Is there a way to modify this to include rows that may be added?
What I want to do is in column 5 row 1, I want it to show a value only if all 4 columns, row 1 are filled in. For example in the picture I want to show a blank in the first 8 rows but to start showing a value on the rest of the rows, in this example IPE 240 to be the first value. When it shows this value from this row I want it to obtain the value with the highest percentege inside. For example in this picture the correct value first value to be shown in column 5 will be IPE (84%)
Ive done this code so far: =IF(AND(B256<>"",D256<>"",F256<>"",H256<>""),Here I want it to show the value on the row that has the highest percentege,"")
I have a spreadsheet we use as a "Stock Location guide" and the critical colums are as follows, Column A = Location, Column B = Date and Column F = Material Description. The following code is what we have been using to sort the guide in order of F, B and then A :
[Code] ..........
What we want to do is swap "A" and "B" so "A" is sorted before "B" and also to change the way"A" is sorted. Certain cells in "A" are yellow and I want to be able to sort by Cell color with yellow on top.