Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default advance level of sorting data? by Ting

I have got a column of data like below:
Y
Y
Z
X
Z
X
Y
X

how could I use the excel function to make it becomes the following?
A B C D
1 Y X Y X
2 Y Z
3 Z X


The rule is,
1) once there is a change from X to Y / Y to X , new column will be applied.
2) Z will stick with the previous result in the same column

Please help cause I have so many data need to be proceed now
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,391
Default advance level of sorting data? by Ting

Not tested much, but something like this ?

Private Sub CommandButton1_Click()
Dim SortRange As Range
Dim DestinationRange As Range
Dim RowOffset As Long
Dim ColOffset As Long
Dim Cell As Range
Dim OldChar As String

Const DEST_RANGE As String = "B1"
Const STICKY_CHARS As String = "Z" 'Or "Z,T,etc

Set SortRange = Range("A1:A8")
Set DestinationRange = Range(DEST_RANGE)

For Each Cell In SortRange
'Cell.Select
If (InStr(1, Cell.Value, STICKY_CHARS) 0) Or OldChar = Cell.Value Then
RowOffset = RowOffset + 1
Else
OldChar = Cell.Value
RowOffset = 0
ColOffset = ColOffset + 1
End If
Range(DEST_RANGE).Offset(RowOffset, ColOffset).Value = Cell.Value
Next

End Sub

NickHK

"Ting Li" <Ting wrote in message
...
I have got a column of data like below:
Y
Y
Z
X
Z
X
Y
X

how could I use the excel function to make it becomes the following?
A B C D
1 Y X Y X
2 Y Z
3 Z X


The rule is,
1) once there is a change from X to Y / Y to X , new column will be

applied.
2) Z will stick with the previous result in the same column

Please help cause I have so many data need to be proceed now



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
How to Shuffle the data at ROW level. Anil Reddy Excel Discussion (Misc queries) 2 March 13th 07 12:58 PM
Problem with search and replace data,thanks for you help in advance. yoyo2000 Excel Discussion (Misc queries) 1 June 20th 06 03:56 AM
how to eport health level 7 data to excel gm New Users to Excel 1 April 14th 06 10:33 PM
Advance function of excel to get sorted data Charlie Excel Worksheet Functions 1 April 3rd 06 03:43 PM
Pull data - Advance Filter lil''bibbib Excel Worksheet Functions 1 June 29th 05 03:08 AM


All times are GMT +1. The time now is 07:15 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"