PC Review


Reply
Thread Tools Rate Thread

Data sorting problem

 
 
Compass Rose
Guest
Posts: n/a
 
      30th Jul 2008
Excel 2003

I have a pivot table which draws data from a sheet in my workbook that is
constantly being updated. After I update the data, I update and sort the
pivot table with:

ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.Range("K").Select
Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers

Column K has data in it that looks like this before the sort:

22900400000F-GW
542A0612-13(L)S
2312120000000ME
etc…

After the sort of column K and performing some LEFT, MID and RIGHT functions
on the data, putting the results into columns A to D , some of the data in
column A looks like this:

229
230
2306
2309
231
2312
2313
233
etc…

I would like the data to be sorted like this:

229
230
231
233
..
542
542A
..
2306
2309
2312
2313
etc…

What change to the sort coding do I have to do to have the data in the order
I want?

TIA
David

 
Reply With Quote
 
 
 
 
Gary Brown
Guest
Posts: n/a
 
      30th Jul 2008
Use the Value( ) function around the info in Col A to make them numbers
instead of text. They will then sort the way you want.
--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"Compass Rose" wrote:

> Excel 2003
>
> I have a pivot table which draws data from a sheet in my workbook that is
> constantly being updated. After I update the data, I update and sort the
> pivot table with:
>
> ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
> ActiveSheet.Range("K").Select
> Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
> Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
>
> Column K has data in it that looks like this before the sort:
>
> 22900400000F-GW
> 542A0612-13(L)S
> 2312120000000ME
> etc…
>
> After the sort of column K and performing some LEFT, MID and RIGHT functions
> on the data, putting the results into columns A to D , some of the data in
> column A looks like this:
>
> 229
> 230
> 2306
> 2309
> 231
> 2312
> 2313
> 233
> etc…
>
> I would like the data to be sorted like this:
>
> 229
> 230
> 231
> 233
> .
> 542
> 542A
> .
> 2306
> 2309
> 2312
> 2313
> etc…
>
> What change to the sort coding do I have to do to have the data in the order
> I want?
>
> TIA
> David
>

 
Reply With Quote
 
Compass Rose
Guest
Posts: n/a
 
      30th Jul 2008
Gary, thanks for the response.

The problem is that column A isn't sorted - column K, which is one of the
columns in the pivot table, is the one that is sorted. Column A is populated
by applying a formula to all the rows in column K after it is sorted. The
formula that I use in column A is:
=IF(MID(K1,4,1)="0",LEFT(K1,3),LEFT(K1,4))

How can column K be sorted to give the results I'm looking for?

David

"Gary Brown" wrote:

> Use the Value( ) function around the info in Col A to make them numbers
> instead of text. They will then sort the way you want.
> --
> Hope this helps.
> Thanks in advance for your feedback.
> Gary Brown
>
>
> "Compass Rose" wrote:
>
> > Excel 2003
> >
> > I have a pivot table which draws data from a sheet in my workbook that is
> > constantly being updated. After I update the data, I update and sort the
> > pivot table with:
> >
> > ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
> > ActiveSheet.Range("K").Select
> > Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
> > Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
> >
> > Column K has data in it that looks like this before the sort:
> >
> > 22900400000F-GW
> > 542A0612-13(L)S
> > 2312120000000ME
> > etc…
> >
> > After the sort of column K and performing some LEFT, MID and RIGHT functions
> > on the data, putting the results into columns A to D , some of the data in
> > column A looks like this:
> >
> > 229
> > 230
> > 2306
> > 2309
> > 231
> > 2312
> > 2313
> > 233
> > etc…
> >
> > I would like the data to be sorted like this:
> >
> > 229
> > 230
> > 231
> > 233
> > .
> > 542
> > 542A
> > .
> > 2306
> > 2309
> > 2312
> > 2313
> > etc…
> >
> > What change to the sort coding do I have to do to have the data in the order
> > I want?
> >
> > TIA
> > David
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem sorting data clcnewtoaccess Microsoft Excel Misc 6 10th Feb 2009 12:56 AM
Data sorting problem Gracewood Microsoft Excel Misc 2 31st May 2008 01:42 AM
Problem sorting data =?Utf-8?B?c2NvdHR5ZGVs?= Microsoft Excel Programming 6 28th Jul 2007 01:27 PM
Problem with Sorting Data reggiebu Microsoft Excel Misc 2 9th Jun 2005 09:37 PM
data sorting problem =?Utf-8?B?UG9uZw==?= Microsoft Excel Worksheet Functions 0 18th Feb 2005 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:24 AM.