How do I bring up the select cells dialog ?
John,
I've replied inline to discuss several areas of the code, to see if I
understand it right.
Sub main()
Dim myRow As Integer
Dim myString As String
Dim newRow As Integer
newRow = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
'Where Sheet2 is the target and Rows count identifies the number of rows to
be populated with data.
'I notice the End(xlUp) value is -4162 and the (Rows.Count... Value is 65536
' This may need changed, because the text is pasted into a populated
worksheet. In order to get the
'data to match, i.e. one record to each row, the data needs to start in (2,
5)
myRow = 1
'Points to the first row
For i = 1 To Cells(Rows.Count, "B").End(xlUp).Row
'For all the cells in Column B...
If Cells(i, 2) = "Attribute" Then
myRow = i + 1
Do Until Cells(myRow, 2) = ""
'If the Cell in the second column is Attribute then myRow = the cells below,
until a blank cell is reached.
If myString = "" Then myString = Cells(myRow, 2) Else myString = myString &
", " & Cells(myRow, 2)
'Mystring = one or more cells
myRow = myRow + 1
'Moves to the next row
Loop
'Unsure what this does, but I notice if I remove it I get an "If without End
If block" error statement
Sheets("Sheet2").Cells(newRow, 5) = myString
'Cope mystring into Sheet2, a new row, Column5. John, this pastes the text
into Column 5 on the last
'populated row of the Sheet, downwards. How do I start at the second row of
column 5?
'I tried changing it to Cells(2, 5) but this pastes, only the final entry
into (2, 5).
newRow = newRow + 1
'newrow = next row
End If
myString = ""
'Clear myString
Next
End Sub
'Regards
'Dylan
|