+ Reply to Thread
Results 1 to 7 of 7

how to loop through rows in excel

  1. #1
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    how to loop through rows in excel

    Hi eveyone,

    i have a requirement. its to find a specific word ('MO') in a notepad and copy certain values from the line where that specific word found and paste those values into an excel cell. the specific word 'MO' occurs multiple times in the notepad. for each occurrence the corresponding values must be pasted into a next row in the excel. so I am using a Do until to find the word 'MO'.

    But I got stuck in pasting the next occurrence of values into the subsequent rows. I guess i should use For loop in the code to get this through.
    But i don't know where.

    Can someone please help

    My code so far

    Please Login or Register  to view this content.
    Last edited by sugaprasad; 02-09-2015 at 08:10 AM.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: how to loop through rows in excel

    Hello,

    Try this code:
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: how to loop through rows in excel

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    08-04-2009
    Location
    Golborne England
    MS-Off Ver
    2013
    Posts
    85

    Re: how to loop through rows in excel

    Hi,

    You need to track the current row and add one to it each time you paste in new data. They this code. It should start on row 1 each time and write data down until complete.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: how to loop through rows in excel

    Hi thank you so much. But there is one issue i face with the code you have suggested. the value for 'ART' is getting pasted in cell A1. but the value of ID is getting pasted into B2 instead of B1

    can you please advice

    screenshot for your reference

    output.jpg

  6. #6
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: how to loop through rows in excel

    Thank you Norie & JimBobBowie.

    Norie's code works great you are a life saver

  7. #7
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: how to loop through rows in excel

    Hello,

    Hi thank you so much. But there is one issue i face with the code you have suggested. the value for 'ART' is getting pasted in cell A1. but the value of ID is getting pasted into B2 instead of B1
    It's because your original code was:
    Please Login or Register  to view this content.
    otherwise I would have suggested this :

    Please Login or Register  to view this content.

+ 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. Loop Across Columns...If Blank Cell, Loop Down Rows
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2014, 07:05 PM
  2. Loop Across Columns If Blank Cell Loop Down Rows
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2014, 10:22 AM
  3. Do-While loop within a do-while loop? Dealing with changing number of rows
    By Motox in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2012, 12:59 AM
  4. [SOLVED] Excel loop error -- 25 rows okay, but 30 too many
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-26-2006, 05:05 AM
  5. [SOLVED] Excel loop to delete redudent rows
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-13-2005, 01:05 PM

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