Excel Forum,
After numerous posts I am finally getting closer to achieving my objective. Unfortunately, I just noticed an issue in my code that I think is due to the .row function I am using. Please help me find a way to preserve the reference key I am looking up.
My code is doing a great job searching for and returning the right values, however, the primary key look up value gets altered when I run the code. This would not be a problem, but I need to refer to the reference number more than once in my code.
In other words, if I am looking up value 4010 in column A, returning the row number and then using that row number and a static column number to return a value in my sheet, that works great. However, after running the code, the original lookup value, 4010 is changed to the row number. Later in the code when I look for 4010 again, I will not be able to find it.
Ultimately, my goal is to pull a few key values from my sheet and then inset them into a model in another workbook. Attached is a sample worksheet with the code saved and below is a small portion of the code.
Thank you for your help!
' searches for T-12 income variables
' optimum rent
Set keyRange = Range("a1", Range("a65536").End(xlUp))
Set keyRow = Columns(1).Find(what:="4010", LookIn:=xlValues, lookat:=xlPart)
If keyRow Is Nothing Then
MsgBox "not found"
Else
keyRow = keyRow.Row
MsgBox "found on row " & keyRow.Row
End If
opRentT12 = (Cells(keyRow, 15))
Bookmarks