View Single Post
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default function problem

Sub Test()
Dim iLastRow As Long
Dim i As Long
Dim iRow As Long
Dim iRow2 As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
iRow = 2
Range("B1").Value = GetLetter(Range("A1").Value)
Range("C1").Value = GetNumber(Range("A1").Value)
For i = 2 To iLastRow
iRow2 = 0
On Error Resume Next
iRow2 = Application.Match(GetLetter(Cells(i, "A").Value), _
Range("B:B"), 0)
On Error GoTo 0
If iRow2 0 Then
Cells(iRow2, "C").Value = Cells(iRow2, "C").Value & "," & _
GetNumber(Cells(i, "A").Value)
Else
Cells(iRow, "B").Value = GetLetter(Cells(i, "A").Value)
Cells(iRow, "C").Value = GetNumber(Cells(i, "A").Value)
iRow = iRow + 1
End If
Next i
Columns("B:C").Sort key1:=Range("B1"), header:=xlNo

End Sub

Private Function GetLetter(cell As String)
Dim iPos As Long
iPos = InStr(cell, " ")
GetLetter = Right(cell, Len(cell) - iPos)
End Function


Private Function GetNumber(cell As String)
Dim iPos As Long
iPos = InStr(cell, " ")
GetNumber = Left(cell, iPos - 1)
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"chindo" wrote in
message ...

I have a column with number 1-9 in order (skus), and a second column
with either the letters a, b, or c as follows:

1 a
2 c
3 b
4 c
5 b
6 b
7 b
8 c
9 a

I need a formula or program that would analyze these two columns and
return 2 columns in this format: (first column is either a,b, or c and
the second column is a list of the skus associated with the letter as
follows)

a 1,9
b 3,5,6,7
c 2,4,8

Any help would be greatly appreciated, i am new to excel programming
and have been trying to figure this out for hours.


--
chindo
------------------------------------------------------------------------
chindo's Profile:

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