+ Reply to Thread
Results 1 to 9 of 9

Looping with find and replace

  1. #1
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Looping with find and replace

    Hi,

    Can someone tell me how loop this code downwards over the A and B columns? Right now, it works on sheet 1 only to replace all instances of the text in Sheet 3, A1, with the text in Sheet 3, B1, but I want it to do the same thing again, replacing A2 with B2, etc, and then stop when it hits a blank cell in the A column.

    Please Login or Register  to view this content.
    Thanks for reading

  2. #2
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: Looping with find and replace

    try this
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: Looping with find and replace

    Your question is not clear.
    If you change A column with B column you dont need loop code.
    You just need copy B column and paste to A column...
    Regards...
    Sub DontForgetThese()
         If Your thread includes any code Then Please use code tags...
         If Your thread has been solved Then Please mark as solved...
         If Anybody has helped to you Then Please add reputation...
    End Sub

  4. #4
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Looping with find and replace

    Thanks a lot, that's exactly what I was looking for!

  5. #5
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Looping with find and replace

    Okay, maybe I spoke a little too soon... The loop does exactly what's required, it just crashes the program right after. Could it be that it isn't stopping when it hits the blank cells?

  6. #6
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: Looping with find and replace

    Assume you are testing with more data than just A1 and B1, with no blank cells, right ?

    Can you describe "crashes" ?
    and "right after" ?

    Does it fault with anything highlighted ?

    May be upload a sample worksheet.

  7. #7
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Looping with find and replace

    Thanks for the reply. By "crashes", I mean that the program performed all the search and replaces like it's supposed to, then the program locks right up, with the cursor turning into the rotating icon thing. I've attached a sample sheet with the macro assigned to the "Re-execute Searches" button. There's nothing highlighted, since once you've run it, you have to restart the program.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: Looping with find and replace

    Problem is due to my assumption that Sheet3 would be "Sheet3", not "Sheet2".
    change this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    Hope that works for you.

  9. #9
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Looping with find and replace

    Thanks, that's working exactly as it should now.

+ 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. looping Find and Replace over two columns
    By Monkihunta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2015, 04:52 PM
  2. [SOLVED] Looping through range to replace data
    By venkatpvc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2013, 07:34 PM
  3. [SOLVED] looping replace function
    By igoodable in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-08-2013, 05:26 PM
  4. Looping through values to Replace
    By vncntj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-22-2012, 11:13 AM
  5. Looping to replace particular word
    By newbie13 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-06-2009, 07:16 AM

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