![]() |
lookup,copy, paste macro??
I have searched Google and the groups for this, but unable to find.
Need a macro to take a entered value in any cell on Sheet 1, column A, look up that value on Sheet 2, column A, go one row over to col. B, copy the cell, then paste it into Sheet 1, column B, next to the entered value. Just like Vlookup, only copypaste . Need to paste the cell contents, not just values. any and all help GREATLY appreciated. |
lookup,copy, paste macro??
Hi Hugh
If I've understood you correctly then this should do it ... Sub doIt() ' first get your sheet1 column A lookup value from whichever rowNumber .. let's make it 4 rownumber = 4 lookupValueA = Sheets("sheet1").Cells(rownumber, 1) 'now iterate through your list on sheet2 (assume list ends with first blank cell encountered) rowPointer = 1 While Sheets("sheet2").Cells(rowPointer, 1) < "" If Sheets("sheet2").Cells(rowPointer, 1) = lookupValueA Then lookupValueB = Sheets("sheet2").Cells(rowPointer, 2) ' get adjacent value in column B End If rowPointer = rowPointer + 1 Wend 'now put that value in column B in sheet1 Sheets("sheet1").Cells(rownumber, 2) = lookupValueB ' bingo ... it's inefficient in that it looks through the whole of Sheet2's values ... but what the heck! ' btw it assumes no duplication of values in your list sheet2 End Sub |
lookup,copy, paste macro??
Dave, many,many gracious thanks! EXACTLY what was needed!!!
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
All times are GMT +1. The time now is 08:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com