+ Reply to Thread
Results 1 to 5 of 5

On creating a loop

  1. #1
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    On creating a loop

    Dear All,

    Firstly, thanks for this wonderful forum!

    I am trying to create a macro that would perform the following in a loop, and would appreciate any help!

    1) Copy a cell
    2) Ctrl+ Pg Up to another sheet
    3) Ctrl + F
    4) Delete
    5) Ctrl + V to paste info
    6) Space + Shift to select the entire row
    7) Delete
    8) Go back to previous cell
    9) Move downwards by one cell
    10) Loop back to Step 1)

    Currently, once I run the macro, it would always paste the info that was copied during the recording, even if I do a "delete" of the text in the 'find' dialog.

    Is there a way to ensure it does a paste of text selected in Step 1), instead of finding the same info?

    Also, how do I cause it to loop until it has reached the end of the list (or any other methods to cause it to stop, eg. ctrl + Break) ?

    Current code:
    Please Login or Register  to view this content.
    Many thanks!
    Attached Files Attached Files
    Last edited by joelhuang; 11-21-2009 at 03:26 AM. Reason: highlighted text to be found; added attachment in simple text to avoid confusion

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: On creating a loop

    There should be an easier way to do this, is it possible for you to attach a sample workbook showing the original layout, then how you want the end result to be.

  3. #3
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: On creating a loop

    Hi, I have posted an example sheet
    The "Original" contains some info that I would like to delete, if it is also found in the second worksheet; that is, the macro is to copy from the second sheet, and attempt to find it from "Original", and once found, it will delete that row.
    Hope this clarifies

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: On creating a loop

    Try this , it would work for your example

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: On creating a loop

    Quote Originally Posted by davesexcel View Post
    There should be an easier way to do this
    u reminded me, a vlookup and deleting those that are a match; that would make things perfect and it is easier. sometimes, we look for the solution without thinking if this is the best solution.

    you've solved my problem totally, thanks! :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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