Sort Column Script

I need to have a script in Excel that would allow the sorting of
columns from column "D" to the column before the last column with data.
 I do not want the last column sorted.  The criteria for the sort is in
row 1 (Name of an employee).  Additional columns will be inserted
between column "D" and the last column so they need to be sorted.  I
hope this is clear.  Can someone please assist me?  Thank you!

Bernie

0
bml66 (24)
1/22/2007 2:51:37 PM
excel.newusers 15348 articles. 1 followers. Follow

3 Replies
636 Views

Similar Articles

[PageSpeed] 26

Bernie

How can someone named Bernie NOT know how to do this?   ;-)

Sub BernieSort()
    Range(Range(Range("D1"), Range("D1").End(xlDown)), _
      Range("D1").End(xlToRight)(1, 0)).Sort _
      Key1:=Range("D1"), Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
        DataOption1:=xlSortNormal
End Sub

HTH,
Bernie
MS Excel MVP


"Bernie" <bml66@aol.com> wrote in message 
news:1169477497.141710.205600@51g2000cwl.googlegroups.com...
>I need to have a script in Excel that would allow the sorting of
> columns from column "D" to the column before the last column with data.
> I do not want the last column sorted.  The criteria for the sort is in
> row 1 (Name of an employee).  Additional columns will be inserted
> between column "D" and the last column so they need to be sorted.  I
> hope this is clear.  Can someone please assist me?  Thank you!
>
> Bernie
> 


0
Bernie
1/22/2007 6:43:18 PM
LOL, that's because this Bernie is not a genius and you are.

It works perfectly, thank you so much for the help.

Bernie


Bernie Deitrick wrote:
> Bernie
>
> How can someone named Bernie NOT know how to do this?   ;-)
>
> Sub BernieSort()
>     Range(Range(Range("D1"), Range("D1").End(xlDown)), _
>       Range("D1").End(xlToRight)(1, 0)).Sort _
>       Key1:=Range("D1"), Order1:=xlAscending, Header:=xlNo, _
>         OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
>         DataOption1:=xlSortNormal
> End Sub
>
> HTH,
> Bernie
> MS Excel MVP
>
>
> "Bernie" <bml66@aol.com> wrote in message
> news:1169477497.141710.205600@51g2000cwl.googlegroups.com...
> >I need to have a script in Excel that would allow the sorting of
> > columns from column "D" to the column before the last column with data.
> > I do not want the last column sorted.  The criteria for the sort is in
> > row 1 (Name of an employee).  Additional columns will be inserted
> > between column "D" and the last column so they need to be sorted.  I
> > hope this is clear.  Can someone please assist me?  Thank you!
> >
> > Bernie
> >

0
bml66 (24)
1/23/2007 4:32:15 PM
Bernie,

Glad to hear that it worked OK for you.  We all have to start with _zero_ 
experience - soem of us have just been around longer than others....

Bernie


"Bernie" <bml66@aol.com> wrote in message 
news:1169569935.628479.111380@m58g2000cwm.googlegroups.com...
> LOL, that's because this Bernie is not a genius and you are.
>
> It works perfectly, thank you so much for the help.
>
> Bernie
>
>
> Bernie Deitrick wrote:
>> Bernie
>>
>> How can someone named Bernie NOT know how to do this?   ;-)
>>
>> Sub BernieSort()
>>     Range(Range(Range("D1"), Range("D1").End(xlDown)), _
>>       Range("D1").End(xlToRight)(1, 0)).Sort _
>>       Key1:=Range("D1"), Order1:=xlAscending, Header:=xlNo, _
>>         OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
>>         DataOption1:=xlSortNormal
>> End Sub
>>
>> HTH,
>> Bernie
>> MS Excel MVP
>>
>>
>> "Bernie" <bml66@aol.com> wrote in message
>> news:1169477497.141710.205600@51g2000cwl.googlegroups.com...
>> >I need to have a script in Excel that would allow the sorting of
>> > columns from column "D" to the column before the last column with data.
>> > I do not want the last column sorted.  The criteria for the sort is in
>> > row 1 (Name of an employee).  Additional columns will be inserted
>> > between column "D" and the last column so they need to be sorted.  I
>> > hope this is clear.  Can someone please assist me?  Thank you!
>> >
>> > Bernie
>> >
> 


0
Bernie
1/23/2007 5:52:31 PM
Reply:

Similar Artilces:

How to Merge Date from 3 columns to 1
I have a spreadsheet where the date is spread over 3 columns I,J & K and I wish to merge them to Column B in the format dd-mmm-yyyy as shown below. B I J K 02-Feb-2003 02 Feb 2003 27-Mar-1999 27 Mar 1999 01-Apr-1978 Apr 1978 01-Jan-1998 1998 14-Jun-2002 14 Jun 2002 Where there is a blank for the day in 'Column I' I need it to copy as 01 and where there is a blank for the month in 'Column J' I need it to copy as Jan. Where all 3 column...

Where's the Sort by New Message option?
Not sure when the layout of the newsgroups changed but I can't seem to find the ability to sort by new message in a thread instead of sorting by just the original thread date. That was hugely helpful as I could follow along and see what threads were still active. If you're gonna hang around in the newsgroups (any newsgroups), you may want to start using a newsreader. Microsoft Outlook Express can do it for you. Saved from a previous post: You may want to connect to the ms newsserver directly: If you have Outlook Express installed, try clicking on these links (or copy and paste i...

How to sort account list?
I'm using MS Money 2004 Small Business. In the account list, my accounts are catagorized by and in this order: - bank accounts - credit accounts - investment accounts - loans and liabilities - asset accounts TOTAL BALANCE In the above view, I cannot easily determine totals for assets and liabilities. The following view does this. - bank accounts - investment accounts - asset accounts SUBTOTAL -loans and liabilities SUBTOTAL TOTAL BALANCE How do I get the above view? Thanks, Brett I don't use Small Business. But you can run a Net Worth report to get total assets and ...

Sorting
Hi, is it possible to use variable for sorting? Something like: declare @sort varchar(10) SET @sort='column1 DESC' SELECT ROW_NUMBER() OVER (ORDER BY @sort)AS rowId, * FROM table Is dynamic SQL only option? Thank you, Simon On 15/04/2010 11:28, simon wrote: > Hi, > > is it possible to use variable for sorting? > > Something like: > > declare @sort varchar(10) > SET @sort='column1 DESC' > > SELECT ROW_NUMBER() OVER (ORDER BY @sort)AS rowId, * FROM table > > Is dynamic SQL only option? You can use CASE to he...

Unhiding Column A
I am using Excel 2003 SP2 and I have a spreadsheet with column A missing. I have followed all the Help Menu advice. I can navigate to column A and hit Format Column Unhide or Format Column Width, but to no avail. It is either hidden or set to zero width, but in any case, it will NOT show up. I have searched all the group postings, been to Microsoft.com help (yea, right) and done everything I can think of. Even installed a macro I found to unhide columns by macro. Any help would be most appreciated. John13 try selecting the cells button to the left of the column headers and on top o...

Comparing and extracting from two columns
Hi all, I have two columns of data. Column A is a list of approx. 20,000 ZIP codes, column B is a selected list of approx. 1600 ZIP codes. How can I compare the two and remove all of the entries in A except those that match B. I would also like to have A sorted so that the identical entries line up with B. There may be entries in B that are not in A, so I would like A to contain a blank cell where the match would be. I used =IF(VLOOKUP(B1,A:A,1,FALSE),"MATCH","") to highlight the matching ZIP codes in A, but that does not remove the unwanted ZIP codes or sort them...

Row/Column labels not displayed.
Hi I'm using Excel 2002 A spreadsheet I've been given to use only displays the row/column labels upto 73/X respectively. I've never seen this before. Any ideas how I can set this up? TIA Dave F. Further to my previous mail, the movement of the selected cell by using the cursor or clickin/dragging "Dave F." <df@bh.cv.fg> wrote in message news:OzcDG$60EHA.3364@TK2MSFTNGP12.phx.gbl... > Hi > I'm using Excel 2002 > > A spreadsheet I've been given to use only displays the row/column labels > upto 73/X respectively. > > I've never s...

Can I convert a column into a row?
Excel Question. I simply want to convert a column of figures [each in different cells] into a row with a similar number of cells. Must be simple, but can't seem to find how to do it. Thanks for any replies, guys!! Select the cells in the column you want to paste in the row. copy (control C). Select the same number of cells in a row, click Edit > Paste Special. Select transpose. Click ok. - Mangesh "Lenworth" <Lenworth@discussions.microsoft.com> wrote in message news:CBEBCC94-3B52-46D1-934C-224E3C234E6B@microsoft.com... > Excel Question. I simply want to convert ...

Row names will not move with sort
Each row in my summary table in Sheet1 is hyperlinked to a corresponding table in Sheet2 with additional details. I need to move the rows in my summary table (Sheet1) and preserve the links to and from the details tables (Sheet2). I found that I can move rows in Sheet1 with cut & insert and the hyperlinks are maintained. I can travel from a row in summary table (Sheet1) to details table (Sheet2) and back, even after the corresponding row (Sheet1) was moved. But if I sort the rows in Sheet1 the links from Sheet2 back to corresponding rows in Sheet1 lead to presorted locations. Apparen...

COUNT function 2 Columns
I have two columns of data, CATEGORY and NUMBER, and want to be able to COUNT the number instances where CATEGORY = X and NUMBER = Y. I know how to use the COUNT function on each column, but I don't know how to use it on two columns. Thanks! James, how about something like this =SUMPRODUCT((A2:A25="test")*(B2:B25=24)) -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 2003 ** remove news from my email address to reply by ema...

sorts not sorting
OK- Thanks to everyones help I now i have a list i can work with... but there are a few problems.... the zips are all 5 digit and now i have to sort them... the problem is, THEY WONT SORT CORRECTLY!!!!!!! The numbers are not in order... some are but a lot are not... is there anyway to fix this???? i need to sort them by zip code but cant seem to get them to do it correctly.. any ideas??? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ You are going to be far better of...

import- number- sort?
I imported this data into a spread sheet- I tried to format it to number, but when I sort it- I get : 37.08 4.33 4.79 4.8 42.56 5.94 Whats up with this? Thanks Brent Hi Brent, Install the TrimAll macro, select the column and invoke the macro from Alt+F8 http://www.mvps.org/dmcritchie/excel/join.htm#trimall Directions to install and use a macro at http://www.mvps.org/dmcritchie/excel/getstarted.htm#havemacro I expect that you have spaces or CHAR(128) "Required Blank" characters in you data you can check is =LEN(A1) --- HTH, David...

sorting macro #3
I need to sort on 8 cells in a row and on 1500+rows. I can do it one at a time but I know there must be an easier way. Can ANYONE HELP? C3:J3 I need these cells sorted and then down to C1532:J1532 I did create a macro to sort after I selected them but still one at a time. Does it have to be a macro? I can edit a macro but don't really know how to program them. Yes, it has to be a macro. The following should do it. This macro loops through all the entries in Column C, and in each row it sorts the values in Columns C:J. HTH Otto Sub SortRows() Dim rColC As Range Dim i As...

Can we sort a form and also be able to enter new records.
Hi, It is possible to sort the data on a form and also be able to enter new and edit the existing records in it. Cheers! On Tue, 15 Jan 2008 15:41:16 -0800 (PST), Rex wrote: > Hi, > > It is possible to sort the data on a form and also be able to enter > new and edit the existing records in it. > > Cheers! I assume you mean "Is it". The form sort order has nothing to do with editing or adding new records, so the answer is yes. If you cannot edit or add new records, make sure the form's record source, if it is a query, is updateable. Some queries are not. O...

Sorting checking register
How do i sort my check register in Money 2004 Deluxe so that uncleared transactions appear below cleared transactions? In Quicken i could click on the column to provide that sort. In microsoft.public.money, Dean wrote: >How do i sort my check register in Money 2004 Deluxe so >that uncleared transactions appear below cleared >transactions? In Quicken i could click on the column to >provide that sort. You don't. Available choices are chosen by clicking View at the top of the register. ...

using addrress books to sort incoming mail
I use address books to sort incoming mail. An odd thing: depending on how the sender's name comes across, it doesn't get caught by the filter (amd moved to the "Family Mail" Folder I have set up. for example: my mom and dad's email (from momanddad@somedomain.com) comes as from that address. However, in my contacts, they are listed by their names: John and Mary Smith, with momanddad@somedomain.com as their email address and John and Mary Smith as the display name. What have I done wrong? TIA 1. The big ONE - failed to post your version of Outlook. Rules operate at ...

Unmerge so I can sort
I coy/pasted data into Excell and when I try to sort it I get "This operation requires merged sells to be identically sized". I understadn the work around in KB but how do I find which sells are merged? I wouldn't bother looking. I'd just remove all the merged cells from the range to sort. Select that range format|cells|alignment tab uncheck the merge cells box But if you wanted to search, you can do it via process of elimination. Select a range, format|cells|alignment tab. If that merge cells box is checked, then the whole selection is merged. If it's grey, t...

Column Heading #3
My column headings are displayed as numeric. For instance, cell A-1 is now R-1C1. Any ideas on how to correct? Happy holidays. "Matt" <anonymous@discussions.microsoft.com> wrote in message news:007c01c3c8ab$a9f5ffe0$a301280a@phx.gbl... > My column headings are displayed as numeric. For > instance, cell A-1 is now R-1C1. Any ideas on how to > correct? > > Happy holidays. Tools > Options > General tab Uncheck "R1C1 reference style". ...

Rule @ script order
Hi there Trying to create a rule using the rule wizard, where a script runs first and the item copy is second. It is insisting on running the copy part before the script. Anyway to fix this? -- Adam S. If it won't work as you desire in the rule, you will need to create two rules- first one with the script - second one with the copy. The first rule should not use stop processing action. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Outlook Tips by email: dailytips-subscribe-request@list...

sorting issue
Hi, When a range of columns are highlighted and a sort is performed on only one column empty cells above the sort display first. How can this be prevented. I know when there is data in any of the other column but not on the column being sorted this will happen. Any thoughts? Pat Are you sure the cells are really empty? They don't contain spaces or even formulas that evaluate to "". (Even formulas converted to values that returned "")? Pat wrote: > > Hi, > > When a range of columns are highlighted and a sort is performed on only one > column em...

Weird column prefixes in filtering expressions
Hello, In an Access 2003 ADP application, I have a bound continuous form. Filtering is enabled. Usually, when user invokes "Filter by Selection", the corresponding filter strings (Me.Filter) contain simple expressions like ((Manufacturer_Name="Cisco")) In particular, those expressions usually refer to the underlying recordset's columns directly, without using prefixes/qualifiers of any kind. So far so good... I've noticed, though, that in some circumstances, the names of columns in the filter expressions get prepended by the form's name. For example, li...

Sort not sorting all rows
I'm using Excel 2000. have created a document, uploaded it to google docs and spreadsheets, exported it as a doc, converted it to a spreadsheet (excel) and uploaded it again to google docs. It's not a complicated file - no calculations or anything, just a simple log to enable us to collaborate on change requests and website faults. New requests are assigned a number incrementally one higher than the previous. So we need to sort on the Log number column to see what the last logged number was. However, it sorts most of the spreadsheet and leaves the same 5 rows unsorted at the...

Querying Recipient Policies from script
Any idea how to construct an ldap query to extrapolate all the email addresses policies out of the recipient policies. So i I'm not totally sure what you're trying to accomplish, but we have a VBS script here that dumps the recipient policies to a text file for us. If you email me directly (remove the online from my address) I'll be happy to send it to you. Thanks, Richard Roddy Microsoft Exchange Support This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- >Thread-Topic: Querying Recipient Policies from script >...

Sort date by day and not year
Need to sort birthdates by month and day; ignore year. Ex: Would like to sort like list below: 3/02/1997 3/15/2002 3/21/1996 Not like this: 3/21/1996 3/02/1997 3/15/2002 Please help and thank you for your help. Kathy Hi one way: - add an additional helper column (lets ay B) - insert the following formula in B1 (if column A stores your list): =MONTH(A1) - copy this formula for all rows - sort with this helper column -- Regards Frank Kabel Frankfurt, Germany Kathy wrote: > Need to sort birthdates by month and day; ignore year. > > Ex: > Would like to sort like list below: >...

automatically updating a column
I have two columns, A and B, where I manually add a number to col. A every day. Col. B is sum of all numbers from beginning in col. A. There is an easy formula for col. B, e.g., b2=a2+b1. But every day, after entering the number in col. A, I have to copy one down in col. B. How can I have that copying done automatically as soon as I make an entry in col. A? On Feb 17, 4:53 pm, "cmar" <cm...@ne.rr.com> wrote: > But every day, after entering the number in col. A, > I have to copy one down in col. B. How can I have > that copying done automatically as soon as...