View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default I need help with VB code

Sub formatData()

NewRow = 1
With Sheets("sheet1")
RowCount = 2
Do While .Range("A" & RowCount) < ""
Num = .Range("A" & RowCount)
Data = ""
For ColCount = 3 To 10
If .Cells(RowCount, ColCount) = "T" Then
If Data = "" Then
Data = ColCount - 3
Else
Data = Data & ", " & (ColCount - 3)
End If
End If
Next ColCount
With Sheets("sheet2")
.Range("A" & NewRow) = Num
.Range("B" & NewRow) = Data
NewRow = NewRow + 1
End With
RowCount = RowCount + 1
Loop
End With

End Sub


"ILoveMyCorgi" wrote:

I have an Excel file:
# Date Per0 Per1 Per2 Per3 Per4 Per5 Per6
Per7
10001 8/25/2008 T T T T T
T
etc. for approximately 50 rows with different data

The output to display on a new worksheet as follows:
10001 0, 1, 3, 4, 5, 7 [there needs to be a space after the comma]

If I can get help on this I'd be appreciative. Thanks for all your help.