+ Reply to Thread
Results 1 to 7 of 7

Help/Advice regarding Find-->offset-->replace

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Help/Advice regarding Find-->offset-->replace

    Hi Everyone

    I'm having some difficulty with VBA code where I am trying to use a range of cells as search criteria within another range. Once I find the variant I need I want to offset 1 cell to the left and replace the contents of said cell with a predefined variant which is linked to the search string.

    I have tried using "cells.find" however this does not work as it does not pick up all strings in my search range, it simply glosses over duplicate values. I can get around this by using "cells.replace" however I cannot work out how to encorporate an "offset" into the code here to select my cells on the left.

    I want to find all values within sheet2 range A1:A6 inside sheet 1 range C2:C7 and replace B2:B7 with new data predefined either inside the code or on sheet 2. I have attached a simplified version of the spreadsheet I'm looking to sort through for anyone to have a look. Examples of code I have been trying can be found in Sub Test() I would really appreciate any help you guys can give?

    Thanks!!
    Attached Files Attached Files

  2. #2
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Help/Advice regarding Find-->offset-->replace

    Insert this as a new module:
    Please Login or Register  to view this content.
    Hope this helps

  3. #3
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Help/Advice regarding Find-->offset-->replace

    If your range is going to expand from C2:C100 for example and sheet2 range A1:A1000 for example then you should use this code:
    With this code the range can expand and decrese and it will only used the cells with values in it
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Help/Advice regarding Find-->offset-->replace

    Hi Stojko89

    Thank you very much for the code it is greatly appreciated however the code still ignors my duplicate values. It is these duplicate values which are the problem and they are something I cannot get around unfortunately. I need to find absolutely every occurance of these numbers in my range. Do you have any other ideas or suggestions?

    Thanks again!

  5. #5
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Help/Advice regarding Find-->offset-->replace

    Wow...I have no idia I'll call someone that knows this stuff I hope

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help/Advice regarding Find-->offset-->replace

    This will search and replace multiple times as needed:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help/Advice regarding Find-->offset-->replace

    Any feedback, Winchester?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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