URGENT HELP PLZ! Search and Update VBA function.
Dash wrote:
Hi all! I've been trying to make a function where the code searches an entire column for a value given by a cell (range). Example: Worksheet1, CELL B11 has value 809 Search worksheet2 cells A:A for value in worksheet1,cell B11 (in this case, 809) If that value is found, then update Column G in that row with the value of worksheet1 Cell P2 Else, appear a msgbox saying ERROR! Dash, I'm not sure how the code you posted related to your question, but the following does what you've described in your post. HTH, post back if not. Nik Sub NikTest() Dim Target_Value Dim NikCell As Range Dim Any_Yet As Boolean Target_Value = Sheet1.Range("b11").Value Any_Yet = False For Each NikCell In Intersect(Sheet2.UsedRange, Sheet2.Range("a:a")).Cells With NikCell If .Value = Target_Value Then .Offset(0, 6) = Sheet1.Range("p2") Any_Yet = True End If End With Next If Any_Yet = False Then MsgBox ("Didn't find any") End Sub |
All times are GMT +1. The time now is 10:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com