+ Reply to Thread
Results 1 to 12 of 12

Find and Replace using cells on different sheets

  1. #1
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Find and Replace using cells on different sheets

    I'm trying to make the macro find values from column A on Sheet1 in column A on Sheet2. If that value is found, then it will use Column B from Sheet1 to replace a value on Column B in Sheet2.

    So Sheet1 will look like this.
    A Annie
    B Billy
    C Charles
    Sheet2
    A Lee
    (empty) (empty)
    C Lopez
    Wanted change in Sheet2
    A Annie
    (empty) (empty)
    C Charles

    I've been trying to make a loop out of it, since the actual sheet will have like 40 rows to find and replace.
    Please Login or Register  to view this content.
    Last edited by Exceloof; 07-18-2019 at 12:51 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: Find and Replace using cells on different sheets

    Are the A, B, C, etc Rows?

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: Find and Replace using cells on different sheets

    If you mean what I think you mean, this might do it.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Find and Replace using cells on different sheets

    Quote Originally Posted by jolivanes View Post
    Are the A, B, C, etc Rows?
    No, they are values in the column.

    So Cell A1 has value "A", Cell A2 has value "B", Cell A3 has value "C".

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: Find and Replace using cells on different sheets

    Did you happen to try the code?

  6. #6
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Find and Replace using cells on different sheets

    I did, and it works beautifully.

    How can I edit the code so that it works with Column C instead of B? I'm assuming it has to do wit the Offset

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: Find and Replace using cells on different sheets

    Yes, change the (, 1) to (, 2)

    If you want to, you can change this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    so it'll skip the empty cells in Sheet1.
    Last edited by jolivanes; 07-18-2019 at 02:13 PM. Reason: Additional info added

  8. #8
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Find and Replace using cells on different sheets

    Quote Originally Posted by jolivanes View Post
    Yes, change the (, 1) to (, 2)
    You beautiful human being

    Thanks!

  9. #9
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Find and Replace using cells on different sheets

    Am I understanding the code correctly?

    Please Login or Register  to view this content.
    I was trying to use find replace, but this method is almost like coding out the steps of find replace.

    Could you explain the Countif section?

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: Find and Replace using cells on different sheets

    Glad it works for you. I added some info to Post #7. Don't know if you seen it.

  11. #11
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Find and Replace using cells on different sheets

    Got it, thank you very much

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: Find and Replace using cells on different sheets

    All the code does is loops through the cells in Column A of Sheet1 and checks if the value of that cell exists in Column A of Sheet2 with Countif.
    It checks a range to see if it meets a certain criteria, in this case the value of a cell. A result of zero (0) means it did not.
    If it does not, it just skips and goes to the next cell.

+ 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. [SOLVED] Find and replace in several (not all) sheets
    By blackberry2012 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2019, 11:49 AM
  2. [SOLVED] Replace blank cells with ZERO using Find Replace
    By makinmomb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2014, 04:47 PM
  3. [SOLVED] Find & Replace Matching Cells Across Multiple Sheets
    By texmexcel in forum Excel General
    Replies: 5
    Last Post: 12-15-2013, 05:25 AM
  4. [SOLVED] Find & Replace All Sheets Using VBA
    By tmontg2 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-28-2012, 04:06 PM
  5. Copmpare/Find and replace cells in two separate workbooks across multiple sheets
    By jmarrxx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2012, 09:53 AM
  6. Find and replace on all sheets
    By Cornwell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-22-2010, 10:41 AM
  7. Find, and replace but copy cells before replace
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2007, 08: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