PDA

View Full Version : [SOLVED] Count Rows From Specific Column - Row Number



dj44
09-01-2018, 03:44 AM
Good staurday folks,


A quick one I hope


I just wanted to output the result in Column K From Row 5





Sub Combine_Cols()

Dim i As Long, j As Long, k As Long, l As Long, m As Long, n As Long

Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("test")


For i = 5 To ws.Cells(Rows.Count, 5).End(xlUp).Row
For j = 5 To ws.Cells(Rows.Count, 6).End(xlUp).Row
If ws.Cells(Rows.Count, 11).End(xlUp).Row = 10000 Then
MsgBox "10000 rows reached"
Exit Sub
Else
ws.Cells(Rows.Count, 11).End(xlUp)(2) = ws.Cells(i, 5) & " " & ws.Cells(j, 6) & " "
End If


Next j
Next i

End Sub





I tried to fiddle about but im not sure why I cant get it to start from row 5 in Column K

Thank you for any tips

p45cal
09-01-2018, 04:10 AM
Sub Combine_Cols()
Dim i As Long, j As Long, k As Long, l As Long, m As Long, n As Long
Dim ws As Worksheet, Dest5n As Range
Set ws = ThisWorkbook.Worksheets("test")
Set Destn = ws.Range("K5")
For i = 5 To ws.Cells(Rows.Count, 5).End(xlUp).Row
For j = 5 To ws.Cells(Rows.Count, 6).End(xlUp).Row
Destn.Value = ws.Cells(i, 5) & " " & ws.Cells(j, 6) & " "
If Destn.Row = 10000 Then
MsgBox "row 10000 reached"
Exit Sub
End If
Set Destn = Destn.Offset(1)
Next j
Next i
End Sub

dj44
09-01-2018, 04:38 AM
Hello P,

nice to see you,

thank you for the revision of the code.

This worksheet was very particular and I needed it to start from row 5 - that was where the column header was

But a google search for hours was of no help to help me get the nuts and bolts in the correct place.

Thank you very much for the great help :)

And good weekend

forum and all