View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Amend Code Help Please

Public Sub Test()
Dim RowData As Range
Dim C As Long
Dim CombData As String
Dim CombNum As Integer

For Each RowData In ActiveSheet.UsedRange.Rows
With RowData
If RowData.Row 2 Then
CombNum = CombNum + 1
CombData = ""
For C = 2 To 6
CombData = CombData & .Cells(1, C).Value & ","
Next C
CombData = CombData & .Cells(1, 7).Value
Debug.Print "Set " & CombNum & "," & CombData
End If
End With
Next RowData
End Sub



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Paul Black" wrote in message
oups.com...
Hi everyone,

I have the following code ...

Option Explicit
Option Base 1

Public Sub Test()
Dim RowData As Range
Dim C As Long
Dim CombData As String
Dim CombNum As Integer

CombNum = 1 <---------
For Each RowData In ActiveSheet.UsedRange.Rows
With RowData
If C 0 Then CombNum = CombNum + 1
CombData = ""
For C = 1 To 5
CombData = CombData & .Cells(1, C).Value & ","
Next C
CombData = CombData & .Cells(1, 6).Value
Debug.Print "Set " & CombNum & "," & CombData
End With
Next RowData

End Sub

... which does produce the right information in the right format.
I would like to amend the code to pick up the groups on a sheet named
"Groups" and in Cells "B3:G?". The groups could be 1 to whatever.
The other thing is that I have had to set the CombNum to 1 when I
think it should start at zero.
If there is a better way to code this I would appreciate any pointers.

Thanks in dvance.
All the Best.
Paul