+ Reply to Thread
Results 1 to 19 of 19

Selecting nonadjacent cells based on text and copy paste value/hard code

  1. #1
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Selecting nonadjacent cells based on text and copy paste value/hard code

    Hello,

    I was curious if there is a way to control find on a page and select all nonadjacent cells containing specific text and then while selected copy paste value?

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    What does specific text mean? One, two, three, four words? Or sentences?
    Paste to where? Same sheet, another sheet, another workbook?
    Last edited by jolivanes; 01-16-2018 at 12:45 PM. Reason: spelling mistake

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    So, if an adjacent cell contains that text do nothing?

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    so I want to hard code all formulas that contain the text HFM. I don't want to move them at all. I want to select them all at once and copy paste values in the cells that they currently sit in. The actual file I have has confidential information so I would have to doctor one up to get it to you as an example.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    What about the adjacent cells?

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,265

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    I would have to doctor one up to get it to you as an example
    Great idea...do just that if you would like a solution...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  7. #7
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    The attached file is an example. What I would want in this example is to Select all of the cells with LEFT in it and copy paste value. In the live document the text would be HFM.
    Attached Files Attached Files

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    Maybe:

    Please Login or Register  to view this content.
    Last edited by xladept; 01-16-2018 at 02:02 PM. Reason: Paste Actual Value

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    Something like this maybe. Change references as required.
    AFAIK, you'll have to loop anyway in order to get the cells that qualify into a Union of cells.
    Might be wrong though.
    I assume you know to always test supplied code on a copy of your original workbook.
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    This is more to the point I think after looking at your example.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 01-16-2018 at 02:04 PM. Reason: code tags

  11. #11
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    Thanks for the code. It doesn't seem to be working however. See the attached. I dropped your code in and change HFM to LEFT to see if it works and it still keeps all of the formulas.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    xladept...your code worked. Thanks for all of your help!

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    Sorry, I misunderstood all this time. I was thinking about the value in the cell.
    My apologies

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    You're welcome!

  15. #15
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    Since I was working on it anyway, these two should work also, although I know you're happy with what you have.
    Possibly for future use, who knows.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  16. #16
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    In case the U.Value shouldn't be all the same value, this modification will get each one:

    Please Login or Register  to view this content.

  17. #17
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    @ xladept
    I have been trying to change your contribution. I hope you don't mind
    I was wondering if your code can be changed to SpecialCells(xlCellTypeFormulas) there where you have ws.Cells.Find(n)
    I tried a few things but no cigar.
    Don't spend any of your precious time on it but if you happen to know, I would be thankful to hear.
    Regards

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    @ jolivanes - I don't know offhand, I'd have to do trial and error but maybe:

    Please Login or Register  to view this content.
    Last edited by xladept; 01-16-2018 at 06:25 PM.

  19. #19
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Selecting nonadjacent cells based on text and copy paste value/hard code

    Thank you very much. I'll play with that for a while.

+ 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] Run Copy Paste Code without Selecting and Switching Sheets
    By Invicta084 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2016, 04:05 PM
  2. [SOLVED] vba code for selecting cells based on activecell
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-01-2015, 02:23 AM
  3. [SOLVED] If calculation to copy rows based on hard coded cells
    By batchjb69 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-31-2014, 03:16 PM
  4. Replies: 0
    Last Post: 10-29-2013, 09:38 AM
  5. [SOLVED] hard one: need to copy and paste a range but as a different name?
    By fredderf81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2013, 12:36 PM
  6. VBA for selecting multiple nonadjacent columns
    By jrtaylor in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-08-2009, 07:27 PM
  7. How do I fill (copy) nonadjacent cells to adjacent cells?
    By BuckyGeorge in forum Excel General
    Replies: 2
    Last Post: 12-22-2005, 12:25 AM

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