+ Reply to Thread
Results 1 to 4 of 4

How to loop through rows and copy range?

  1. #1
    Registered User
    Join Date
    10-08-2024
    Location
    Earth
    MS-Off Ver
    2019
    Posts
    2

    How to loop through rows and copy range?

    first time posting. i feel like this should be straightforward, but I can't get it with For Next Row in Table..

    sorry for the bad formatting, but I have a table that looks like the one below.

    How can I find "Error" in the first row, display the address, and then loop it do the same thing for the rest of the rows? Any help would be appreciated.

    Assume the table below has 5 rows and 6 columns

    1 2 3 Error Error Error
    1 2 3 4 Error Error
    1 2 Error Error Error Error
    1 2 3 4 5 Error
    1 2 3 4 Error Error

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2021
    Posts
    968

    Re: How to loop through rows and copy range?

    Hi there,

    Try the code below (assuming you are after a macro).
    We are looping through all rows on the active sheet and write the address of the FIRST 'Error' for each row into the Immediate window.
    With your sample data, if starting in cell A1, the result would be;
    $D$1
    $E$2
    $C$3
    $F$4
    $E$5

    Let us know how you go with this.

    PS: please check the yellow banner at the top on how to upload a 'sanitized' sample workbook. That would make it much easier for us to see how your data is structured and test offered solutions.

    Please Login or Register  to view this content.
    Last edited by ORoos; 10-08-2024 at 04:24 AM. Reason: Added option to display as Message box
    If your Question is answered; please mark it SOLVED. If you are happy with a member's solution, say 'Thanks' and click the 'Star' to Add Reputation.

  3. #3
    Registered User
    Join Date
    10-08-2024
    Location
    Earth
    MS-Off Ver
    2019
    Posts
    2

    Re: How to loop through rows and copy range?

    THANK YOU!! Will post a worksheet next time

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2021
    Posts
    968

    Re: How to loop through rows and copy range?

    You are welcome, and thanks for getting back to us.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 01-09-2017, 05:22 PM
  2. Loop through files in folder, copy range, Paste range to original workbook
    By knevil in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-09-2016, 05:33 PM
  3. Loop through each folder copy values from range in file1 to named range in file2
    By dafella in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2015, 05:19 PM
  4. Copy 1 cell formula to a range of cells and loop every 3 rows
    By ArtPur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2013, 09:54 AM
  5. Copy range in loop
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2010, 04:44 PM
  6. Copy range from loop
    By malefeous in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 04:29 PM
  7. [SOLVED] Copy range from 1 wks to another w/loop
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1