Results 1 to 3 of 3

Thread: VBA to COPY cell with conditions

  1. #1

    VBA to COPY cell with conditions



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi everyone,

    I have "Sheet1" and "Sheet2"

    In need to add a VBA for conditional cell copy like this :
    IF Sheet1 (Cell"A23") = Sheet2 (a cell in Column"A") THEN copy the "Sheet2" same line cell from column B TO Sheet1("B2")

    To be clear :
    IF Sheet1 (Cell"A23") = Text_To_Find
    SEARCH in Sheet2 (a cell in Column"A") = Text_To_Find (ex: A12)
    THEN Copy B12 TO Sheet1 (Cell"B2")

    Hope my explanations are clear.
    Thanks a lot
    Fouko

  2. #2
    Yeah, I have found the trick with no VBA:

    In the Sheet1 (Cell"B2") I put this :
    Code:
    =VLOOKUP(B2;Sheet2!A1:B50;2;FALSE)
    And it's works !!

    Fouko

  3. #3
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,250
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Sorry that I didn't get here sooner to answer, but I'm glad you worked out a solution. Almost always better to go the formula route instead of VBA if possible.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •