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.
0
GLeeds (3)
8/10/2009 8:26:01 PM
excel 39880 articles. 2 followers. Follow

4 Replies
590 Views

Similar Articles

[PageSpeed] 31

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 Range
    Dim TheRow As Range
    Dim RngToSort As Range
    Set rColC = Range("C3", Range("C" & Rows.Count).End(xlUp))
    Set TheRow = Range("C1:J1")
    For Each i In rColC
        Set RngToSort = TheRow.Offset(i.Row - 1)
        RngToSort.Sort Key1:=Cells(i.Row, 3), Order1:=xlAscending, 
Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
    Next i
End Sub
"GLeeds" <GLeeds@discussions.microsoft.com> wrote in message 
news:82AC5466-4463-47EB-A2BC-9841EB8B2736@microsoft.com...
>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. 


0
8/10/2009 9:30:42 PM
Sub sortcolumnsbyrow()
For i = 3 To Cells(Rows.Count, 3).End(xlUp).Row
Cells(i, 3).Resize(, 8).Sort Key1:=Cells(i, 3), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlLeftToRight
Next i
End Sub


-- 
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com
"GLeeds" <GLeeds@discussions.microsoft.com> wrote in message 
news:82AC5466-4463-47EB-A2BC-9841EB8B2736@microsoft.com...
>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. 

0
dguillett1 (2487)
8/10/2009 9:50:04 PM
Hi Otto,

Thank you for your reponse. I tried Don's first and it worked great.

Thanks again

"Otto Moehrbach" wrote:

> 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 Range
>     Dim TheRow As Range
>     Dim RngToSort As Range
>     Set rColC = Range("C3", Range("C" & Rows.Count).End(xlUp))
>     Set TheRow = Range("C1:J1")
>     For Each i In rColC
>         Set RngToSort = TheRow.Offset(i.Row - 1)
>         RngToSort.Sort Key1:=Cells(i.Row, 3), Order1:=xlAscending, 
> Header:=xlNo, _
>         OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
>     Next i
> End Sub
> "GLeeds" <GLeeds@discussions.microsoft.com> wrote in message 
> news:82AC5466-4463-47EB-A2BC-9841EB8B2736@microsoft.com...
> >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. 
> 
> 
> 
0
GLeeds (3)
8/11/2009 1:08:21 AM
Hi Don,


Thank you sooo much.. This works great. I was getting missed calcs in the 
beginning but found I gave you some wrong info. The number of cells was 7 not 
8 so one minor change and WOW. Works like a charm. It's great to have a 
format like this for someone like me to get some fast easy answers..  Thank 
you MS....

Thanks again....

"Don Guillett" wrote:

> Sub sortcolumnsbyrow()
> For i = 3 To Cells(Rows.Count, 3).End(xlUp).Row
> Cells(i, 3).Resize(, 8).Sort Key1:=Cells(i, 3), _
> Order1:=xlAscending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, _
> Orientation:=xlLeftToRight
> Next i
> End Sub
> 
> 
> -- 
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguillett1@austin.rr.com
> "GLeeds" <GLeeds@discussions.microsoft.com> wrote in message 
> news:82AC5466-4463-47EB-A2BC-9841EB8B2736@microsoft.com...
> >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. 
> 
> 
0
GLeeds (3)
8/11/2009 1:14:01 AM
Reply:

Similar Artilces:

How do I move a chart using a macro?
Hi, all, I have a nice little macro that creates two charts on several worksheets in a workbook. My problem is that it places one chart right on top of the other. I just need to offset it enough to see both charts, or at least to remind myself that there are two of them there. I tried variations of the "Activechart.parent . . . ." commands I found elsewhere on the site, but I always get the debug screen when I get there. I'm using OFFICE 2007 and Vista. Thank you Jim -- JP Cummings Assuming you know what cell you want as the top left cell positio...

POP3 Question #3
We have SBS 2003 and ISA 2004, with Outlook 2003 running on the workstations. We are using Exchange for corporate email, but each user also has several different pop3 email addresses at different ISP's we want to send and receive with (Old email address, Boss's personal email, etc). Right now I am using Outlook to add these additional pop3 accounts for the users, which is working fine. Except that I would like to take advantage of Exchange's spam filtering capabilities and centralized administration of the accounts. Should I be using the POP3 Connector of Exchange i...

bar chart #3
I am trying to make a bar chart. My problem is that excell keeps combining info from 2 different projects and inserts both of them into one bar chart. How do I fix this problem? I assume that you want to see the data as two series in one chart? Put your different projects into different rows, or preferably different columns, select them both, and the Chart wizard should split them into two different series. If that doesn't work, select one series, insert the chart, then go to source data, & add the second series. -- David Biddulph "Ann" <Ann@discussions.micro...

Macro question
Whenever I try to run my macro, nothing happens. When I try to change the security settings through the Tools > Security option, nothing happens. I can do it at home but not at work. Is there a specific reason? I'm the administrator of the computer and I am not connected to any domain. Please help! -- Nocturnal We see this sometimes when another application starts Outlook before you = do and VBA never quite loads properly. Try shutting down Outlook and = using Task Manager (Ctrl+Alt+Del) to make sure it's really, really shut = down before you restart it. You may also w...

macro to save new file (same as tab name)
Hi I am recording macro and want to save the new macro- recorded sheet as the same name as the sheet tab. I do have the tab name in one of the cells A1, using =cell("filename",A1) Example : sheet name week1, want to save new file as week1 I Can copy and paste into existing macro thanks in advance brian -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/excel-new/200601/1 Activeworkbook.SaveAs Filename:=Activesheet.Name -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Brian Thompson via OfficeKB.com" <u1568...

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 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...

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...

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 ...

Search and replace macro needed
I need a macro that will replace a space with a non-breaking space <b>for the selected text only</b> Hi Greg, Why do you need a macro, when you can use a simple Find/Replace operation? Select the desired range then: Find: ' ' Replace: '^s' Click 'Replace All'. -- Cheers macropod [Microsoft MVP - Word] "GregNga" <GregNga@discussions.microsoft.com> wrote in message news:FBBBB44D-6B2D-4445-9DFA-50EBC8BF20FE@microsoft.com... >I need a macro that will replace a space with a non-breaking space <b>for the > se...

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...

Macro filter on query
I need to run 8 append and update queries using the same date range. I created a Form with the "Month" field as the filter and a command button to run the macro to run the Append & Update queries for records in the month range. I can't get the Apply Filter macro to work on the Query Date field. Any suggestions? Apply Filter action will not do what you seek. Your queries must have a WHERE clause that refers in some way to the textbox on the form where you've entered the Month value/data that you want to use in the queries. To assist you further, you need to post ...

MFC Extension DLL #3
Hi, I have a dll, which i want to display a dialog. so i go: DlgClass dlg; dlg.DoModal(); However it always crashes on the DoModal() line. DlgClass hWnd = 0x0000000 And it crashes at HINSTANCE hInst = AfxGetResourceHandle(); with the DoModal() call. Any ideas? On Sep 24, 11:16 am, hamishd <Hamish.D...@gmail.com> wrote: > Hi, I have a dll, which i want to display a dialog. > > so i go: > DlgClass dlg; > dlg.DoModal(); > > However it always crashes on the DoModal() line. > DlgClass hWnd = 0x0000000 > And it crashes at HINSTANCE hInst = AfxGetResourceH...

Exchange System Manager Error #3
I just installed a new certificate on my Enterprise exchange server. I had been using a Small business server as a front end server and recently ran the transition pack to convert to a full Windows 2003 server. I am no longer using the exchange that was on the small business server and have disabled all of the services until I get a chance to remove it. When I try to access public folders from Exchange System Manager, I get the following error: the SSL certificate server name is incorrect ID no: c103b404 Exchange System Manager I am not sure what is causing this. All of the public ...

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...

Email Macro with Outlook Express
Once a week, I am in a position where I have to send between 80-160 emails to 80-160 different email addresses (the store locations in our company). I have an attachment that needs to be sent to each store, and each attachment is unique. However, I have all the attachments in one folder, and all of the attachments have filenames such as Store 101, Store 102, Store 103, etc... I have another file which lists all store numbers in Column A and their respective emails in Column B. Is there a way I can have a macro that does the following: 1. Creates an email with a Subject being the same as the ...

Mailbox limits #3
We have configured mailbox limits on our mail stores using system policies but they do not appear to be working mailboxes are able to exceed these limits and I can not see a pattern to it. I have search the log files and i see no information on the mailbox management re limits beging exceed i have logging turned on. Any Ideas as to validate the configuration On Mon, 13 Dec 2004 11:37:11 -0800, "Nollaig" <Nollaig@discussions.microsoft.com> wrote: >We have configured mailbox limits on our mail stores using system policies >but they do not appear to be working ma...

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...

excel macro...PLEASE HELP!
Hi there, Here's what I would like to know how to execute. Assuming I have created a macro in place in a file. When I open that file, I want that macro to run...how do I do it? Thank your for reading and any suggestions are welcomed! Hi Jack Rename it Sub Auto_open() -- HTH. Best wishes Harald Followup to newsgroup only please. "Jack" <tangjack@yahoo.com> wrote in message news:00e601c38ceb$78b050d0$a301280a@phx.gbl... > Hi there, > > Here's what I would like to know how to execute. > > Assuming I have created a macro in place in a file. When...

starting Word from an Excel macro
I found this piece of code by Bob Phillips that opens a Word document from within an Excel macro. Dim oWord as Object Dim oDoc as Object Set oWord = CreateObject("Word.Application") oWord.Visible = True Set oDoc = oWord.Documents.Open("C:\personal\bob\personal\CV - RP (short).doc") It works fine but it also closes the Excel file that contains the macro. Is there a way to prevent the Excel file from closing? -- russ Russ, There's nothing in that snippet that will close the Excel Application. I think you need to post all yo...

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...

Excel should allow macro on a shared workbook.
We are using excel tables all the time at my company. There are more than 20 people working on the same excel file which has thousands of columns so we use autofilter or some other macros. Shared workbook will help us alot because we will be able to change the file at the same time which is very time saving. Is there any way that macros are allowed at shared workbooks? ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not ...

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. ...

How to turn off editing after I have created a spreadsheet with macros
I have created a spreadsheet with macros and when I call the spreadsheet up on another computer and I click on the buttons I created it takes me to viusal basic to edit. How do I turn this off so I can run the macros? If you need more info please email me. I have tried it on 3 computers and one of the computers will run the macros, but the rest just go into what I call edit mode instead of running the macros. Any help would really be appreciated.--Gary ...