Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
travelersway
 
Posts: n/a
Default Sorting Data


I have informations for transactions:
A1:A10= date
B1:B10= Name
C1:C10 = Costs

There are rows that contain no data. Examle:
rows 1.3.4,9 may have data
rows 2,5,6,7,8,10 would be empty

I'd like to sort the data to elimated the empty rows at the following
locations and show 4 consecutive rows of data. :

A12:A22= sorted dates
B12:B22= Sorted names
C12:C22= Sorted costs



Any help is appreciated, Thanks
Travelersway


--
travelersway
------------------------------------------------------------------------
travelersway's Profile: http://www.excelforum.com/member.php...o&userid=17623
View this thread: http://www.excelforum.com/showthread...hreadid=516707

  #2   Report Post  
Posted to microsoft.public.excel.newusers
Max
 
Posts: n/a
Default Sorting Data

One way .. try tinkering with the 2 subs below

1. Sub SortAscByDateNameCost()

Clears A12:C21 first, then copies A1:C10 to A12:C21,
and then sorts A12:C21 in ascending order
by Date, then by Name, then by Cost
(source lines will be kept together)

2. Sub SortAscIndependently()

Clears A12:C21 first, then copies A1:C10 to A12:C21,
and then sorts *independently* each col within A12:C21
in ascending order (source lines will not be kept together)

To implement:
Press Alt+F11 to go to VBE
Click Insert Module
Copy and paste the 2 subs below into the code window
Press Alt+Q to exit VBE and go back to Excel

In Excel,
Click View Toolbars Forms
Click on the button icon and draw a button somewhere on the sheet

The Assign Macro dialog will pop up
Look for "SortAscByDateNameCost" in the dialog box, select it OK
(or just double-click on "SortAscByDateNameCost")
The above assigns the Sub SortAscByDateNameCost() to this button.
Right-click on the button Edit Text [to rename the button]

Repeat to draw another button, assign "SortAscIndependently"
Right-click on the buttons to select, re-position the 2 buttons
somewhere to the right of A1:C10

Test out running the 2 subs with your sample data within A1:C10 ..
(just click the buttons)

Adapt to suit ..

'------------
Sub SortAscByDateNameCost()
Range("A12:C21").ClearContents
Range("A1:C10").Copy Destination:=Range("A12")
Range("A12:C21").Select
Selection.Sort _
Key1:=Range("A12"), _
Order1:=xlAscending, _
Key2:=Range("B12"), _
Order2:=xlAscending, _
Key3:=Range("C12"), _
Order3:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Range("A1").Select
End Sub

Sub SortAscIndependently()
Range("A12:C21").ClearContents
Range("A1:C10").Copy Destination:=Range("A12")
Range("A12:A21").Select
Selection.Sort Key1:=Range("A12"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Range("B12:B21").Select
Selection.Sort Key1:=Range("B12"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Range("C12:C21").Select
Selection.Sort Key1:=Range("C12"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Range("A1").Select
End Sub
'----------

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"travelersway"
wrote in message
news:travelersway.23uuin_1140988205.6133@excelforu m-nospam.com...

I have informations for transactions:
A1:A10= date
B1:B10= Name
C1:C10 = Costs

There are rows that contain no data. Examle:
rows 1.3.4,9 may have data
rows 2,5,6,7,8,10 would be empty

I'd like to sort the data to elimated the empty rows at the following
locations and show 4 consecutive rows of data. :

A12:A22= sorted dates
B12:B22= Sorted names
C12:C22= Sorted costs



Any help is appreciated, Thanks
Travelersway


--
travelersway
------------------------------------------------------------------------
travelersway's Profile:

http://www.excelforum.com/member.php...o&userid=17623
View this thread: http://www.excelforum.com/showthread...hreadid=516707



  #3   Report Post  
Posted to microsoft.public.excel.newusers
Max
 
Posts: n/a
Default Sorting Data

... I'd like to sort the data to elimated the empty rows.

If all that you're really after (going by your edited line above)
is to delete the blank rows within A1:C10,
then this sub may suffice ..

Sub RemoveBlankRows()
Range("A1:C10").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
Range("A1").Select
End Sub

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #4   Report Post  
Posted to microsoft.public.excel.newusers
travelersway
 
Posts: n/a
Default Sorting Data


Max,

Thank you ,Ill try this. Is there a formula that can be written that
would perform this automatically without the buttons?

Thanks again,

Travelersway


--
travelersway
------------------------------------------------------------------------
travelersway's Profile: http://www.excelforum.com/member.php...o&userid=17623
View this thread: http://www.excelforum.com/showthread...hreadid=516707

  #5   Report Post  
Posted to microsoft.public.excel.newusers
Max
 
Posts: n/a
Default Sorting Data

"travelersway" wrote
Max, Thank you ,Ill try this.


You're welcome !

Is there a formula that can be written that
would perform this automatically without the buttons?


Based on your latest "edited" requirement to eliminate empty rows within a
source range, I don't think so. Formulas can only evaluate/return values in
the cells they are in, they cannot delete empty rows.

Try the Sub RemoveBlankRows() in my last response. Think it should work ok.
Just implement the sub and assign it to a forms toolbar button, as per
earlier steps provided.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ranking query JaimeTimbrell Excel Discussion (Misc queries) 2 February 16th 06 08:09 AM
sorting data and automatic graphs timc Charts and Charting in Excel 3 January 27th 06 08:37 PM
Inserting a new line when external data changes Rental Man Excel Discussion (Misc queries) 0 January 11th 06 07:05 PM
Automatically sorting data leehutch Excel Discussion (Misc queries) 4 August 22nd 05 06:36 AM
how do you prevent data from changing values when sorting linked . Cassie Excel Discussion (Misc queries) 0 March 4th 05 10:45 AM


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"