+ Reply to Thread
Results 1 to 13 of 13

Search Column for 'X' and copy 1 cell to the left.

  1. #1
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Search Column for 'X' and copy 1 cell to the left.

    Hi All,

    I'm getting there with my project, I just need this little bit of guidance form those much better than I

    In the Code Bellow I can check if the cell is numeric however what I need to do next is ' If numeric then search a column for that number as copy what's to the left (Either copy/array).

    I need to search Sheet2 Column B for the 'Ncell' value and copy the word to the left i.e. If Ncell is B12 then copy A12.

    Please Login or Register  to view this content.
    My assumption would be after the
    Please Login or Register  to view this content.
    bit I would add something like search sheet 2 ("B:B") - If found then copy with an offset of -1

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Search Column for 'X' and copy 1 cell to the left.

    Maybe:

    Please Login or Register  to view this content.
    Not sure if this does what you want. It goes down Column B and finds the numbers then copies the Column A value. However, it does nothing with it since you don't mention what you want (destination) after the cell in Column A is copied.

  3. #3
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Search Column for 'X' and copy 1 cell to the left.

    Hey John,

    Sorry I should have mentioned....I wanted to copy and overwrite the original number in cell A2 (With the word it's copied and picked up form sht2)

    So Far with your code I've got:

    Please Login or Register  to view this content.
    I tried adding a sheet 1 activation and then - Range("A2").Value = Ncell however that doesn't work. I'm assuming because the Ncell value would be the original number it searched for?

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Search Column for 'X' and copy 1 cell to the left.

    Can you attach a sample sheet showing how the data would look before the macro (Sheet1) and then after the macro (Sheet2).

  5. #5
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Search Column for 'X' and copy 1 cell to the left.

    Hey John,

    The website doesn't let me attach an excel doc form my computer (It never has done) so I always have to resort to screenshots sadly. I shall try and describe it as best I can below to perhaps help?


    Sheet 1:

    I'm importing arrays to this sheet.

    On import, Cell A2 will either contain a number or a word. If its a word the fine, if its a number then I Have a list on sheet 2 which has numbers and their corresponding words.

    Sheet 2.

    Column A Column B

    Dog 1
    Cat 2
    Owl 3
    Pidgeon 4
    Rat 5
    Hawk 6
    Zebra 7
    Mouse 8
    Lion 9
    Cow 10



    So if the imported array puts the word Hawk in sheet 1 - Cell A2 then That's fine, nothing is changed.
    If the number 6 is imported and placed into to Sheet 1 Cell A2 then I want it to look for the number 6 on sheet 2 - Copy the word beside it i.e. hawk then go to sheet 1 and place Hawk in cell A2.

    Hopefully that makes it clearer?

  6. #6
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Search Column for 'X' and copy 1 cell to the left.

    Hey John,

    The website doesn't let me attach an excel doc form my computer (It never has done) so I always have to resort to screenshots sadly. I shall try and describe it as best I can below to perhaps help?


    Sheet 1:

    I'm importing arrays to this sheet.

    On import, Cell A2 will either contain a number or a word. If its a word the fine, if its a number then I Have a list on sheet 2 which has numbers and their corresponding words.

    Sheet 2.

    Column A Column B

    Dog 1
    Cat 2
    Owl 3
    Pidgeon 4
    Rat 5
    Hawk 6
    Zebra 7
    Mouse 8
    Lion 9
    Cow 10



    So if the imported array puts the word Hawk in sheet 1 - Cell A2 then That's fine, nothing is changed.
    If the number 6 is imported and placed into to Sheet 1 Cell A2 then I want it to look for the number 6 on sheet 2 - Copy the word beside it i.e. hawk then go to sheet 1 and place Hawk in cell A2.

    Hopefully that makes it clearer?

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Search Column for 'X' and copy 1 cell to the left.

    Perhaps?

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Search Column for 'X' and copy 1 cell to the left.

    You Sir, are a genius.

    This is spot on
    Thank you!

    Its amazing how different it is form what I original started with!

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Search Column for 'X' and copy 1 cell to the left.

    You're welcome. Glad to help out and thanks for the feedback.

  10. #10
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Search Column for 'X' and copy 1 cell to the left.

    Hey John, Sorry to bother you again.

    If Column A and Column B changed to Column N and Column P...which bit would a change to accommodate the offset of picking up the word from column N?

    I've messed around and it collects the correct row but not correct column!

    Thanks

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Search Column for 'X' and copy 1 cell to the left.

    Try:

    Please Login or Register  to view this content.
    I'm guessing this will work for you. Adjust as required.

  12. #12
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Search Column for 'X' and copy 1 cell to the left.

    Hey John,

    My Mistake - I mean the two letters on the second sheet - But from what you have highlighted, I have been able to figure it out

    Please Login or Register  to view this content.
    Again Thank you - It all works! Woop

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Search Column for 'X' and copy 1 cell to the left.

    Again welcome. Glad you figured it out.

+ 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] Trying to search for the result in the column to the left of the reference.
    By Beach Walker in forum Excel General
    Replies: 1
    Last Post: 08-02-2014, 11:55 PM
  2. [SOLVED] Search a column for a value and if it exists copy text from corresponding cell in column A
    By badlydrunkboy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-02-2014, 06:13 AM
  3. [SOLVED] Need MACRO to copy the text in the cell left of first selected cells (a column), paste all
    By joobeng in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-16-2013, 06:42 AM
  4. Replies: 8
    Last Post: 06-04-2013, 04:36 AM
  5. [SOLVED] When a search term appears in column I, copy the value from column H to a new cell.
    By ShallowJamm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-28-2012, 06:36 PM
  6. Macro to search column with last value and insert TOTAL column to the left
    By sbara906 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-02-2009, 11:34 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