Consulting

Results 1 to 3 of 3

Thread: Count Rows From Specific Column - Row Number

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location

    Count Rows From Specific Column - Row Number

    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    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
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •