PDA

View Full Version : paste after copy



phil-e
01-30-2006, 09:35 PM
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
philhttp://vbaexpress.com/forum/images/smilies/102.gif

XLGibbs
01-30-2006, 09:39 PM
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.

phil-e
01-30-2006, 09:50 PM
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.

XLGibbs
01-30-2006, 09:57 PM
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:

'find the match in column d and create a reference to it:

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

myMatch.Offset(,3).PasteSpecial

phil-e
01-30-2006, 10:57 PM
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