Consulting

Results 1 to 4 of 4

Thread: Looping through a Range of Data

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Location
    Nova Scotia
    Posts
    83
    Location

    Looping through a Range of Data

    How can I loop through a range of data (A5:H20) such that the following code is called over and over going down cells E and G until it reaches the bottom with no data

    Call CODE_ABC(Range("E11"), Range("G11"))

    Part 2:
    How can do this based on specific text in column A (for example when it only sees the name "Task A", Task "B", etc.).

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Hi and welcome to the forum.

    This is one of many ways:

    Sub Ked()
        Dim x As Long
        For x = 5 To 7 ' E-G Column numbers
            If Cells(1, x) = "Task A" Then Call CODE_ABC(Cells(11, x)) 'Only call sub if condition met
        Next
    End Sub
    Semper in excretia sumus; solum profundum variat.

  3. #3
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    This is cross posted here:
    https://www.mrexcel.com/forum/excel-...ange-data.html

    I answered this on the mrexcel site, so i am not happy: please read about cross posting:

    https://www.excelguru.ca/content.php?184

  4. #4
    VBAX Regular
    Joined
    Jan 2018
    Location
    Nova Scotia
    Posts
    83
    Location
    Apologies on the cross posting. I value these types of sites very much. I read the link.

    Please take this as my sincere apologies.

    BTW, the code works great. Thank you

Posting Permissions

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