+ Reply to Thread
Results 1 to 10 of 10

Searching cells then copying/pasting and deleting macro

  1. #1
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Searching cells then copying/pasting and deleting macro

    Hi All,

    I am looking for help with a macro.

    I need to search column C for the text "X". If an "X" is found, I need to copy the text from the cell directly left of it and paste it into a seperate worksheet into cell B2, then go back to the original worksheet and delete the cell with "X" on it and the cell to the left.

    Can anyone help me?

    Thanks
    Last edited by JayWeb; 06-27-2009 at 05:41 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code Help

    Welcome to the forum, Jay.

    Please take a few minutes to read the forum rules, and then amend your thread title accordingly.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Sorting cells then copying/pasting and deleting macro

    Jay

    Your post infers the text "X" will appear only once in column C of the first sheet. Is this so? If not, please explain what you wish to do with the other text "X" items.

    then go back to the original worksheet and delete the cell with "X" on it and the cell to the left.
    Do you mean "delete" or "clear" the cell with text "X" and the cell to the left?

    J

    PS: where does the "sort" come into play?
    Last edited by jaslake; 06-26-2009 at 10:28 AM. Reason: another question

  4. #4
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Sorting cells then copying/pasting and deleting macro

    Thanks for your reply,

    There will only be one "X" at a time, if there is more than one "X" they should just be ignored.

    I mean delete the cell with the X and the cell to the left, I don't want there to be empty cells.

    Sorting doesnt come into it, I think I meant to put search. My Bad.

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Searching cells then copying/pasting and deleting macro

    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  6. #6
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Searching cells then copying/pasting and deleting macro

    Exactly what I wanted.

    Thanks!

  7. #7
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Searching cells then copying/pasting and deleting macro

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    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

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Searching cells then copying/pasting and deleting macro

    Neat Mudracker; I'm always interested in learning how to tighten up my code. Your solution is 6 lines of code. Mine was 17. Obviously, I'll look at yours when I encounter a similar situation.

    The only thing I would comment on is that the "X" is hard coded. My solution gave the user an input box "What are you looking for". However, perhaps JayWeb doesn't require this.

    Thanks.

    J

  9. #9
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Searching cells then copying/pasting and deleting macro

    An input box could be added & would increase code by 2 lines

    1 to Dim a variable
    2 to ask for what to search for via an input box

  10. #10
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Searching cells then copying/pasting and deleting macro

    A input box is not required, it will always be a "X". 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