MrExcel Message Board
Survive a PC disaster with Carbonite Online Backup


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 03:54 PM   #1
beth804
 
Join Date: Mar 2004
Posts: 6
Default Macro to sort

I hope this is easier to understand and that this is posted in the right place.

Cells: C6 to T61, that's the 6-row from the C-column to th T-column. Then down to 61-row.

Trying to sort, ascending, by the I-column, starting at cell I6. I had a macro that worked fine and then for some reason messed up. It is now only sorting from C6 to P61. Completely ignoring columns Q, R, S and T - even though they were included when I recorded the macro.

For example:

Before sort: - in this example sorting by the second column.
a 12 b c
d 03 e f
g 11 h i

After sort:
d 03 b c
g 11 e f
a 12 h i

Notice that rows 3 & 4 have not changed.

My question is why is it doing that and how can I fix it?
beth804 is offline   Reply With Quote
Old Mar 30th, 2004, 03:56 PM   #2
beth804
 
Join Date: Mar 2004
Posts: 6
Default Re: Macro to sort

Before I confuse anyone - I meant "columns 3&4", not rows.
beth804 is offline   Reply With Quote
Old Mar 30th, 2004, 03:56 PM   #3
bolo
 
Join Date: Mar 2002
Posts: 292
Default Re: Macro to sort

It would really help if we could see the code to fix it
bolo is offline   Reply With Quote
Old Mar 30th, 2004, 03:57 PM   #4
onlyadrafter
 
Join Date: Aug 2003
Location: England
Posts: 4,584
Default Re: Macro to sort

Hello,

Can you post the code for this macro as well, or at least the SORTING part.
__________________
-------------------------
Hope this is helpful.
-------------------------
only a drafter,
but broadening my Excel knowledge.
onlyadrafter is offline   Reply With Quote
Old Mar 30th, 2004, 04:10 PM   #5
beth804
 
Join Date: Mar 2004
Posts: 6
Default Re: Macro to sort

Selection.Sort Key1:=Range("I6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
beth804 is offline   Reply With Quote
Old Mar 30th, 2004, 04:20 PM   #6
onlyadrafter
 
Join Date: Aug 2003
Location: England
Posts: 4,584
Default Re: Macro to sort

Hello

Sorry, I didn't mean just the line you sent, I thought you may have a load of code and the few lines that do the range selection then the sort would be OK.

You must have a line before this with

range(some cells).select

can you sent the whole macro, if it is small.
__________________
-------------------------
Hope this is helpful.
-------------------------
only a drafter,
but broadening my Excel knowledge.
onlyadrafter is offline   Reply With Quote
Old Mar 30th, 2004, 04:48 PM   #7
beth804
 
Join Date: Mar 2004
Posts: 6
Default Re: Macro to sort

That's the whole thing. I didn't write this code. I highlighted the cells, hit record new macro, went up to sort, then stopped recording. That is the whole thing. That is the whole thing.
beth804 is offline   Reply With Quote
Old Mar 30th, 2004, 05:05 PM   #8
bolo
 
Join Date: Mar 2002
Posts: 292
Default Re: Macro to sort

YOu should hit record macro BEFORE you highlight the cells. THat way the highlighting of cells is also repeated. At the moment you are just doing the sort on a few columns and rows because only those cells are selected.

Hope this helps.
bolo is offline   Reply With Quote
Old Mar 30th, 2004, 05:30 PM   #9
beth804
 
Join Date: Mar 2004
Posts: 6
Default Re: Macro to sort

It worked - for now. Hopefully it won't mess up again.

Thanks.
beth804 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 10:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.