Find matching cell and return value of a different cell
On Fri, 25 Jan 2013 20:40:05 +0000, pmterp wrote:
[color=blue][i]
'Ron Rosenfeld[_2_ Wrote:
;1608881']On Fri, 25 Jan 2013 00:37:25 +0000, pmterp
wrote:
To use this User Defined Function (UDF), enter a formula like
=MatchClientAmt(B2)
in some cell on Sheet: "Summary"
===================================
Option Explicit
Function MatchClientAmt(ClientNum)
Dim ws As Worksheet
Dim c As Range
For Each ws In ThisWorkbook.Worksheets
If Not ws.Name = "Summary" Then
With ws.Range("A:A")
Set c = .Find(what:=ClientNum, LookIn:=xlValues, _
lookat:=xlWhole)
If Not c Is Nothing Then
MatchClientAmt = .Item(RowIndex:=16)
Exit Function
End If
End With
End If
Next ws
MsgBox ("Client Number Not Found")
End Function
===============================
Thanks a lot. This is what I need. However, I've made a few
modifications to my 2013 workbook and the cells are different. I've
tried making the changes in the code but I'm not getting something
right.
2013 Workbook changes
Still unique values is Column B and want the data returned to Column C
of summary page.
Individual Client pages now will have the unique number in cell F2.
The value I need returned is in cell K22 (but K - O) is merged
together.
Any MORE help would be greatly appreciated.
Well, if the Client Number on the Client page will always be in F2; and the value you want returned will always be in K22, you could use a routine that merely looks at all the F2's on sheets that are not named "Summary":
==================================
Option Explicit
Function MatchClientAmt(ClientNum)
Dim ws As Worksheet
Dim c As Range
For Each ws In ThisWorkbook.Worksheets
If Not ws.Name = "Summary" Then
With ws
If .Range("F2") = ClientNum Then
MatchClientAmt = .Range("K22")
Exit Function
End If
End With
End If
Next ws
MsgBox ("Client Number Not Found")
End Function
===================================
Be careful with merged cells, however. They can become confusing to use.
|