+ Reply to Thread
Results 1 to 18 of 18

Copy/Paste from partial match between worksheets

  1. #1
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Copy/Paste from partial match between worksheets

    Stuck...

    Please Login or Register  to view this content.
    I get a compile error: Expected: expression at Next:

    Please Login or Register  to view this content.
    What I am working to do is loop through all worksheets on specific rows (oRows) partially matching that cell with column A in sheet22. If there is a match, column B (sheet22) should be copied and pasted to this sheet, the oCell that is working + 13 (down 13 spots to row 15 (for the first oRow).

    The oRow loop works very well in another macro I have, so there is no issue there.

    The issue is with the partial match, copy, paste. (the .formula portion)

    Any thoughts?

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/Paste from partial match between worksheets

    This seems not show any error, but not sure if it works.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Thanks AB33. Very near off work, so I'll try tomorrow and reply back here.

  4. #4
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Hi AB33. No errors. But no actions...

    Now I have to come up with another way to try this out...

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/Paste from partial match between worksheets

    What I am working to do is loop through all worksheets on specific rows (oRows) partially matching that cell with column A in sheet22. If there is a match, column B (sheet22) should be copied and pasted to this sheet, the oCell that is working + 13 (down 13 spots to row 15 (for the first oRow).

    It would be easier to use the find function. The find function loops through a column/s and find the match(Including partial match).

    Some idea


    Please Login or Register  to view this content.
    Last edited by AB33; 06-19-2013 at 10:02 AM.

  6. #6
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Interesting. I'll test this on a test workbook that I have setup.

    What I am doing is importing single line text files for multiple different devices. All of these text files are outputs from running various version commands.
    These are all imported into Sheet22 with the filename being Hostname_date_time_*version*.txt (This is part of the search parameter). The Hostname bit is taken directly from the spreadsheet that I am now working to do the partial match. The date_time stamp is necessary, so it can't be removed.

    My end goal is to have only the latest version imported into the spreadsheet (automatically, I hope...), so there should be only one match per device. Currently, there are multiple lines with a few of the same hostnames. (Which may or may not be important...)

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/Paste from partial match between worksheets

    Added some comments to the above code.

  8. #8
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Test.zip
    Here's a sample xlsm with a folder structure in place similar to what I am doing. A few of the text files are spread through the various folders.

    You'll notice that there are two sets of buttons with the same name. These are my location based macros. (If the button is in column A, it only works that column!)

    I do not have this current macro in this spreadsheet yet. It is in another test spreadsheet with actual data.

    But, I thought I'd get this to you early.

    Edit: Hmm... this doesn't appear to do anything...
    Last edited by ussenterprise; 06-19-2013 at 10:37 AM.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/Paste from partial match between worksheets

    The set-up has not been completed.
    This is my understanding:
    You want to search for host names in each sheet.
    This will give you a good start.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Should I see something changed with this macro? Currently, when I run it, nothing happens. I changed the following and tested again with no changes:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Some of this code doesn't make sense to me, but I am fairly new to this... :D

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/Paste from partial match between worksheets

    You are right!

    Please Login or Register  to view this content.
    The lines are saying that if there is a match, then do something.

    Please Login or Register  to view this content.
    Copy the match row in to version sheet.
    After the match is found, we could do lots of things.
    If nothing is found, i.e. no match, the code jumps in to end if and find the next match and so on
    Please Login or Register  to view this content.
    If it has not copied anything, the code is jumping, it will not copy anything.

  12. #12
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Ah. Thanks for the explanation.

    So, at some point I would need to paste the data in a specific location.

    As it turns out, Windows 7 includes a neat little function that I didn't know about. clip.exe. (Which is also available for download).

    I can run my commands and pipe to clip. So, I may be entirely eliminating two or three additional macros if I can get this to work. If I can, I'll post the code.

    FYI, apparently I added to reputation earlier in this post, so I can't add to this latest reply.

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/Paste from partial match between worksheets

    Do not worry about rep. What is important is if you are heading on the right direction. I hope you have picked up few lines today.

  14. #14
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Before I test, here is my first attempt...

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    Got an error. Object expected on the second line.
    Tested the firstline alone. Then did a Control+V to the cell and I do indeed get what I am looking for.
    Now, I just need to figure out the error...

  16. #16
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    To much copy paste. It should look like:
    Please Login or Register  to view this content.
    Problem now is that line 2 doesn't support the .Paste. (Object doesn't support this property or method)

  17. #17
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    So I tried this:
    Please Login or Register  to view this content.
    Which doesn't work either...

  18. #18
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Copy/Paste from partial match between worksheets

    So I added this:
    Please Login or Register  to view this content.
    BAM! It WORKS!!!!!!

    At last. A way to simply redirect output to a spreadsheet!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

+ 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