VBA Script To Sort Data
Jul 8, 2014
I have 3 columns ItemNames, Top Depth and Bottom depth and I would like to sort as follows:
BEFORE
ITEMTOP_MDBASE_MD
A3157.713157.71
B2900.002901.83
B2901.833143.38
B3143.383143.38
C2961.873145.21
C3145.213150.70
C3150.703151.46
C3151.463157.10
C3157.103157.40
C3157.403168.99
C3168.993169.44
C3169.443171.27
C3171.273192.00
AFTER
ITEMTOP_MDBASE_MD
A3157.713157.71
B2900.003143.38
C2961.873192.00
How do I do this?
View 1 Replies
ADVERTISEMENT
Mar 4, 2010
I havet he following code which sorts data. If there is no data to sort I keep on getting a run time error. Could I add something to my code to prevent the run-time error, as sometime there won't be any data to sort. The code runs when I switch to the worksheet in question.
Sub SortMeetings()
Dim iCTR As Integer
Dim yCTR As Integer
Dim zCTR As Integer
zCTR = 11
For iCTR = 12 To 23
For yCTR = 1 To 10
If Len(Range("D" & iCTR).Offset(0, yCTR)) 0 Then
Range("AA" & zCTR).Value = Format(Range("D" & iCTR).Offset(0, yCTR), "HH:MM") & " " & Range("D" & iCTR).Value
zCTR = zCTR + 1
End If
Next yCTR
Next iCTR
Range("AA11:AA" & zCTR).Select
Selection.Sort Key1:=Range("AA11"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
View 9 Replies
View Related
Oct 7, 2013
I have an excel WS1 set up as DB; I want to keep this sheet for data revision. WS2,3, 4, & 5 will be data that is filtered and sorted, using WS1 as source so I want to auto copy the WS1 data. Can I just auto copy WS1 (how do I do that?) then filter and sort in each WS?
View 3 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
May 22, 2012
In the attached spreadsheet I track the performance of my team. I enter the AHT for my team in the work sheet named "AHT Summary".I keep updating this data every month. automatically sort the updated data and rank the agents based on their average AHT. The person with the lowest AHT should be ranked 1. Column is highlighed in green for your reference. Based on this ranking the work sheet named "Ranking" should be updated automatically. Since I am taking a weighted average for all agents, the one who gets the lowest AHT should be ranked 1st . In the ranking work sheet the agent with ranking 1 should be given 100, the second highest ranked person should get 98,third 96,fourth 94 etc.
View 6 Replies
View Related
Feb 25, 2014
I have Sheet1 "MASTER" and Sheet2 "Area1" and Sheet3 "Area2" etc...
My MASTER sheet has a list of employee names and the areas they work in. I have employees working in different areas, and I want to pull a list of employee names from the MASTER working in Area1 (sorted on the MASTER sheet) to column A on Sheet2, then pull a list of employee names working in Area2 to column A on Sheet3, etc...
I want it to do this in such a way that if I add an employee to Area1 on the MASTER data, it will populate that employee in the Area1 Sheet.
So basically, I'm looking at one column on the MASTER sheet to see if the area matches. Then looking at another column on the MASTER sheet to get the name. Then taking that name and transposing it to a new sheet corresponding to the area they work in.
I've attached a sample sheet. I want Column A in the Area1 sheet to reflect all names that show up on the Area1 LIST on the MASTER sheet, and nothing else. I'm using VLOOKUP to pull the rest of the data from the MASTER table.
There is a new sample workbook up now. Couldn't update it sooner due to site outage. I've removed irrelevant data to improve readability and focus on what I'm trying to achieve. Again, the main issue is scraping column E from the Master, and populating a list of all employees who match certain values in Column E on the Master in Column A of the other tabs.
View 2 Replies
View Related
Jun 6, 2014
I would like to be able to sort the data in this one cell alphabetically without retyping the data .ie use a sort function but only for a cell.
For Example cell A1 contains Chris Brown Andy
No commas there. Names are seperated only by spaces.
What function should I use in order to get Andy Brown Chris ?
View 5 Replies
View Related
Sep 6, 2009
In the attached version the "Print Version" tab sorts the values entered into the "Log Entries" tab. When entries are deleted from the "Log Entries" tab they are converted into 'blank' entries and moved to the end in the "Print Version" tab.
However, in earlier versions the "IFERROR" does not appear to work, therefore any blank entries are shown as "#NUM!", which is kind of annoying. If there any way around this? The forumla is shown below. =IFERROR(SMALL('Log Entries'!$A$1:$E$47,ROW('Log Entries'!A1)+COLUMNS('Log Entries'!$A$1:A1)*46-46),"")
View 4 Replies
View Related
Nov 11, 2009
to use a Macro in order to batch process a set of data that will have consistent columns, but may have additional rows.
I have attached the file, three tabs.
1st - Sch of Inv(2): The intended goal
The data is sorted first by Georgraphic Location (A), then Strategy (C), then Substrategy (E). Column F should be the same formula that is currently there, but updated for column I once the information is pulled (I""/$F$29*100). The *100 is to only display the % symbol once. If there's a better way to calculate percentages and only show the symbol on the first one, that would also help. Column I is the place to calculate the data from Tab 2. Column K is your check figures, which are within $5 (due to a miskey probably, not important). Cell F29 will be a manually hard-coded number on each sheet (which would be entered before the Macro is initiated).
2nd - Cost Query: The data source sheet
6 columns, 5 have relevant data. Manager shortname is the 'primary key', but won't need to be displayed anywhere. Region-Strategy Code-Substrategy Name correspond to (A), (C) and (E) on Tab 1. The goal is to sum by each of these factors, then display the one sum on Tab 1. The pull will include column F, but it has no actual value. I'd prefer to be able to just keep it on Tab 2.
3rd - Pivot of Cost Query: The step inbetween?
Here is the proof that the data can be easily pivoted to provide all of the values, but I'm having trouble figuring out how to quickly move those values into the predetermined format of Tab 1.
Questions:
Is there something simple that I'm missing to move the data from the pivot into the predetermined format?
How can I use a macro to take the data on Tab 2, move it into a pivot on Tab 3, then move that data to the format (column I) in Tab 1? Is this process easier without the pivot step in the middle?
View 14 Replies
View Related
Apr 5, 2014
edit the below code? Having problem with the underlined portion. It is always showing the following error message - "Run-time error '1004' -Application-defined or object-defined error".
Code:
Sub Macro1()
'
' Macro1 Macro
[Code]....
View 1 Replies
View Related
Oct 5, 2007
I have a list in rows where I have a ranking formula =COUNT($G$5:$G$81)-(RANK(G5,$G$5:$G$81)+ COUNTIF($G$5:G5,G5)-1)+1 When I sort the rank, ascending. All of the unique numbers sort ascending, but the non-unique numbers sort descending
ex) 1.751
2.52
3.753
418
417
416
View 5 Replies
View Related
Jan 13, 2014
Using DataEntry sheet for data.
Trying to rearrange the data to DataFormatedProperly sheet.
So far all I can accomplish is DataFormatedWrong sheet.
Edit: Not sure what happened but file was NOT understandable before. It should be correct now.
View 2 Replies
View Related
Mar 22, 2014
Im using a pivot with 2 rows entrees and 1 column entree. I would like to sort my data from the biggest value to the smallest. It works for the first group, but when i sort the second the first change aswell and mess with my data.
View 1 Replies
View Related
Jul 8, 2014
I need to sort a database. In the pic you will see what i have and what i need to do.
example.jpg
View 3 Replies
View Related
Jun 30, 2014
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.
View 3 Replies
View Related
Oct 22, 2008
I've found that sorting a column next to one which has drop down boxes set up in it, does not take the options for the drop down boxes (data validation ) with them when being re-arranged. Is there a way to make this possible, or an alternative format I should be using? see example:
If item 4 is the only one available from supplier 3, (As shown by the drop down box options) how do I sort by say, department, and still have the correct options on hand? Sorting by department, the items move, but the data validation info stays where it is, leaving the supplier 3 option for item 1, which is not correct.
View 3 Replies
View Related
Jan 25, 2009
Is there a simple method to bulk data sort?
Explanation:
I run a workbook with worksheets in calendar months (12)
These consist of names in alphabetical order.
If a new name is added to or deleted from all the sheets (I've cracked how to do this) how can I data sort them without doing it sheet by sheet?
View 6 Replies
View Related
Mar 4, 2009
How do I sort chronologically by date?
View 12 Replies
View Related
Apr 10, 2009
We have an issue with sorting rows of data that have formulas in them.
---------------
These formulas are using data from a row which is above the column headers.
For example cell H2 has 160 manually entered in it. It's the number of work hours available in January 2009.
The column header for that column is in Q4 and has a value of 'Jan'
Below this in cell H5 is the formula '=+H2' because the resource in this row is available for 100% of the month.
Another resource in row 22 has the formula '=+H2*0.15' in cell H22 because they are only available 15% of the time that month.
---------------
The problem occurs when we try to sort this data. Most of the cells displays #REF!. Some show a value, but the calculation is wrong.
View 8 Replies
View Related
Dec 12, 2009
Can a sorted array be produced from a table without using code? The attached sample gives a better idea of what I'm trying to do.
View 4 Replies
View Related
Nov 29, 2012
I'm working on a spreadsheet to track student test scores over the course of the school year. Each score set is grouped by student, but we need to be able to realphabetize when new students are added. is there some way to accomplish this?
View 3 Replies
View Related
Apr 30, 2013
1) Imagine i have a row 1 with names, column 1 with bank account numbers, and under each name corresponding to each bank account it says "yes" or "no" depending on whether or not they are authorized on the bank account. How do i make 2 drop down lists, 1 with bank account numbers that produces the names which are authorized on the account and visa versa (list with names showing bank a/c numbers). It needs to be able to be updated easily.
2) Suppose I have the table as described above and another excel file with 1 column as bank a/c's and another column is authorized bank users. In this column however each cell just has a bunch of names for example one cell may contain (james, john, jack, jennifer, bill). Is there anyway to check these names against the ones in the table from the other spread sheet?
View 14 Replies
View Related
Aug 11, 2013
i have a load of data that i dump onto a sheet and i would like to sort automatically with out the need to do it via data and sort
I have attached an example
Can it be do within a lookup?
View 3 Replies
View Related
May 9, 2014
I have a list of data with headings number,name, surname,group. Data needs to be kept in the rows as they are now but I would like to sort the order by group. The group order needs to be:
sm, u17m, u15b, u13b, u11b, sw, u17w, u15g, u13g, u11g. I would like to do this using vba and have a blank row between each group.
View 11 Replies
View Related
Apr 1, 2009
As you can see from the attached spreadsheet. I have a page called Pattern Etch where we enter the data for all the processing done in a single machine.
Each device type is slightly different, and therefore has a different calculation fasctor for its etch time. This all weorks fine. What I had previously was another spreadsheet with the pages b and g in it. This is where the factors are calculated and updated from.
I'd like to make this update automatic, and suspect the easiest way is to combine the two spreadsheets, as in the attached version. Can the sorting of the data from the patternetch page to the apprpriate pages, b and g be done automatically? If so can it be done for many pages as I have cut down the spreadsheet, I actually have 50 variants, each will need its own page (as for b and g).
View 2 Replies
View Related
Feb 17, 2010
I have multiple employees working on different projects. I would like to use a formula or some kind of macro where I can automatically scan an entire worksheet and manipulate the data to show me how much time was spent by each employee on each project. Using the SUMIF command only lets me use one criteria. In my case I need to sum if in the row there is a match with the employee name and the project name.
For example, if Employee A is working on Project 1 then sum the units. I would like everything summarized in a nice table. Attached is a basic example of my sheet.
View 3 Replies
View Related
Nov 7, 2006
I have a workbook with about 30 worksheets (I know not that many, but enough to make me want to automate the following)
They all have the same columns and headers.
I want to sort them ALL based on Column E for example. Is there a way to do this easily, with out having to "manually" sort each worksheet?
View 12 Replies
View Related
Mar 12, 2013
sort data into ranges like in the example below:
1,2,3,4,5,6,10,11,12,15,19,21,27,28,29,30 [Each value is in a cell vertically]
into
1 to 6
10 to 12
15
19
21
27
28 to 30
provide the vba code for this ?
View 1 Replies
View Related
Feb 7, 2014
I'm trying to sort some data that is generated from a PDF. When I copy the PDF into Excel all of the data is placed into one cell. Is there a function or formula I can use in VBA or within the spreadsheet to accomplish this?
For example, the cell may contain "Employee John Employee Steve Employee Dave Employee Jed Employee Mark" in cell A1. I want the function to list John, Steve, Dave, Jed and Mark in separate cells. So I need to get rid of the space bar hits, the word employee and to separate the names to different cells.
A1 currently is "Employee John Employee Steve Employee Dave Employee Jed Employee Mark"
I would like to create a formula to have cells:
A2 = John
A3 = Steve
A4 = Dave
A5 = Jed
A6 = Mark
View 3 Replies
View Related
Feb 19, 2014
I am trying to sort some data and I have gone through the custom sort feature and it is not sorting the data correctly. I am trying to sort from left to right EK6:FE66. The top 3 rows have text and there are numbers from row 9 down. The sort feature sorts the top 3 rows but wont sort the numbers below from left to right. I have set the cells to be formatted as text.
View 1 Replies
View Related