+ Reply to Thread
Results 1 to 16 of 16

Replace data from one column with data in another

  1. #1
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Replace data from one column with data in another

    Hey everybody

    I will try keep this short and sweet...

    As you should be able to see in the attachment I have 3 columns

    The first column is the data I wont to search and replace.

    What I want it to do is for every value in A, loop through B and if it finds the Value in A matches that of B then replace the value in A with the value that is in C.

    So basically B is like a reference column.

    I hope this makes sense. My algorythm is something like this I guess.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jmcall10; 02-19-2009 at 09:28 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA i think search and replace

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    I cant imagine this beeing hard, however I dont have any VBA expereince

    If someone could help that would be much appreciated.

    Thanks in advance

    jmcall10

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Replace data from one column with data in another

    Is this what you mean?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    Ehm, when I created a button and assigned the above code to it it replaced only the first cell in column A with the correct value.

    So it is on the right tracks

    Have you had a look at the excel file I uploaded?

    I have uploaded a new one with the button I attached

    Thanks for your help on this so far.

    jmcall10
    Attached Files Attached Files

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Replace data from one column with data in another

    There was only one match that I could see. It checks column a against B, if they match it replaces a with c

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Replace data from one column with data in another

    roy i think op wants to match anything in col b not the same row

  8. #8
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    Yea I think Martin knows what I mean.

    I want it to check every entry in A again every entry in B if they match then replace it with the C value next to B, so the offset part is working correct.

    That make more sense?

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Replace data from one column with data in another

    Maybe this
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    This is so so close!

    The only problem I see that it has is that it only Checks column A for the lenght of column B. Is that right?

    Other than that it is looking good so far.

    Do you think you know why its not checking all of A?

    Thanks again for all this help

    jmcall10

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Replace data from one column with data in another

    It checks each cell in A, but only works with a cell if there is a value In B. The example only has four cells that have data in a & b. Can you add a sheet that shows your expected results?

  12. #12
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    Ok I have attached the excel spreadsheet.

    Now Column D on this spreadsheet is what Column A should be after the script has ran.

    I hope this makes it clear what Im after now.

    Thanks again

    jmcall10
    Attached Files Attached Files

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Replace data from one column with data in another

    Try this
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    This has worked a treat!

    Thanks a lot for all the help on this matter.

    jmcall10

  15. #15
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Replace data from one column with data in another

    If you are satisfied with the solution(s) provided, please mark your thread as Solved and maybe rate the answer(s) using the scales icon in the post

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  16. #16
    Registered User
    Join Date
    02-15-2008
    Posts
    17

    Re: Replace data from one column with data in another

    Already done that chief

    One step ahead of you...

    Thanks again

+ 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