Consulting

Results 1 to 5 of 5

Thread: paste after copy

  1. #1
    VBAX Newbie
    Joined
    Jan 2006
    Posts
    3
    Location

    paste after copy

    Hello to all. I am having trouble pasting a value. I am doing this with code. I can get a value copied to the clipboard but I can't get the proper cell to paste it in. I can use vlookup to find the proper rowe then set the correct collum, but the problem is that the vlookup value changes. The value to lookup is a range name "FndName" (inputted from a userform text box). The lookup range is "worksheet!D7:38". collum to paste to is "G".

    Hope this makes sense.
    All help is appreciated
    phil

  2. #2
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    You should post your code, it is likely a minor tweak to what you already have...

    but you can find the first empty row below the last occupied row by

    lastrow = Sheets("Sheet1").Range(rows.count,"D").End(xlup).Offset(1,0)

    as a general syntax. There are different ways depending on your code and what needs to happen.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  3. #3
    VBAX Newbie
    Joined
    Jan 2006
    Posts
    3
    Location
    Gibbs, here is what I have for code (this try anyway):
    Sheets("WORKSHEET").Range("d7:d38",FindName + 0, 3).Select
    Selection.PasteSpecial Paste:="ADD_SP_HRS"
    I am looking up names. They are in the range D7:d38, the I need to paste my "value" in collum "G", in the same rowe as the lookup value finds.

  4. #4
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    Okay, that won't work. Post more of the code so i can see how you are finding the data to copy and help you out on this.

    What you want to do is find your matching row and use that as the row to paste in, so you would want to do something like this:
    [vba]
    'find the match in column d and create a reference to it:

    Dim mymatch as Range
    Set mymatch = Sheets("Worksheet").Range("D738").Find(FindName)
    'then use that reference, go 3 columns over (from D to G) and paste there...

    myMatch.Offset(,3).PasteSpecial
    [/vba]
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  5. #5
    VBAX Newbie
    Joined
    Jan 2006
    Posts
    3
    Location
    Thanks Gibbs,
    I haven't got it to work yet but that is the right track. I need to think my logic.

    Thanks again
    phil

Posting Permissions

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