Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Sorting within a cell

Hello Chip,

Megan wanted to have the list of items in one cell in Excel and sort within
the cell. As you know almost anything can be done using VBA (your output in
Col G can be combined back to the original cell) but given the basic
requirement (have a list of part nos which can be printed in newspaper like
columns) I thought that Word would be the best option.

Megan can also have list in different cells in one Col, hide the gridlines
at the time of printing... and distribute them in multiple columns at the
time of printing...

Regards,
Sheeloo

"Chip Pearson" wrote:

I don't think you need to go to Word to do this. You can use the code
below. Change the lines marked with <<<< to your appropriate values.
Separator is the character that separates part numbers in the original
cell. ListCell is the cell that has the list of part numbers.
NumColumns is the number of columns into which you want to split the
part numbers. Destination is the first cell where the part numbers are
written to.


Sub AAA()
Dim ListCell As Range
Dim Count As Long
Dim Destination As Range
Dim V As Variant
Dim N As Long
Dim M As Long
Dim Separator As String
Dim NumColumns As Long
Dim FirstRow As Long

Separator = ";" '<<<< CHANGE
Set ListCell = Range("A1") '<<<< CHANGE
NumColumns = 3 '<<<< CHANGE
Set Destination = Range("G1") '<<< CHANGE
FirstRow = Destination.Row

V = Split(ListCell, Separator)
Count = (UBound(V) - LBound(V) + 1) / NumColumns
For N = LBound(V) To UBound(V)
Destination.Value = V(N)
M = M + 1
Set Destination = Destination(2, 1)
If M Count Then
Set Destination = _
Destination(1, 2).EntireColumn.Cells(FirstRow, 1)
M = 0
End If
Next N

End Sub


This writes the part numbers in their original order. If you want to
sort the part numbers before writing them out to the columns, enter
the following line of code immediately AFTER the V = Split(ListCell,
Separator) line of code:

QSortInPlace V, -1, -1, False, vbTextCompare

The QSortInPlace procedure is available at
http://www.cpearson.com/excel/SortingArrays.aspx. Download the zip
file to some folder (it doesn't matter where) and the unzip the file.
Then in VBA, go to the File menu, choose Import File, and navigate to
where you unzipped the file, and open modQSortInPlace. This will
insert a module into your project that contains the sorting
procedures.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





On Thu, 19 Feb 2009 17:16:01 -0800, Megan
wrote:

I have a spreadsheet where there is a long list of part numbers that
constantly change, get added to, deleted from, etc. and all need to be in one
cell. The problem I have is that the list gets very long and needs to almost
be treated like the COLUMN feature in Word where you can take a long list
and make it read like 3 newspaper columns. Otherwise, each row is way way
too long and the data is on multiple pages when it actually needs to be on
one page and taking up minimal area. Is there any way to do that in one cell
in Excel?

Second part related to the first part above is that after items are
added/deleted to this long list, the remaining info needs to be sorted and
read correctly. This is a weekly report that i will be updating constantly
and not sure how to best approach it - or if there is even a way to do what i
am asking.

The ultimate goal is to have one cell with multiple pieces of data that read
like newspaper columns that I can sort from a to z and always have it fit in
the smallest space in one cell and stioll be readable.


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
sorting in a cell Kim Excel Worksheet Functions 3 November 15th 07 04:46 PM
Sorting numbers within a cell [email protected] Excel Discussion (Misc queries) 9 May 21st 07 01:15 PM
Sub-cell List Sorting Len Excel Discussion (Misc queries) 0 March 30th 06 07:38 PM
Sorting data at end of cell Copper Excel Discussion (Misc queries) 4 February 17th 06 11:40 PM
Sorting by cell Color t2true Excel Discussion (Misc queries) 3 August 13th 05 12:05 AM


All times are GMT +1. The time now is 12:44 PM.

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"