Wheels1978
10-24-2006, 09:45 AM
Hi guys,
It's been a while, but here I am again with something I can't get to work.
I want to lookup a value on the current sheet (Summary) in sheet "Refs" and return the address of the cell on sheet "Refs" that contains the value.
I want to use the Find method for this, so that I can also use FindNext later.
The sub I created may not be nice, but it works. It looks like this:
Sub Test()
Dim SourceRange As Range, InputRange As Range, FindMonth As String
Set InputRange = Worksheets("Summary").Range("A2")
Set SourceRange = Worksheets("Refs").Columns("A:A").Find(InputRange.Value, LookIn:=xlValues)
FindMonth = SourceRange.Address
MsgBox FindMonth
End Sub
Now I want to convert the sub to a UDF. What I created gives me the #VALUE error :confused: . Can anyone tell me why and what I should change?
Function FindMonth(InputRange As Range) As String
With Worksheets("Refs").Columns("A:A")
FindMonth = .Find(InputRange.Value, LookIn:=xlValues).Address
End With
End Function
Thanks a lot for any help!
It's been a while, but here I am again with something I can't get to work.
I want to lookup a value on the current sheet (Summary) in sheet "Refs" and return the address of the cell on sheet "Refs" that contains the value.
I want to use the Find method for this, so that I can also use FindNext later.
The sub I created may not be nice, but it works. It looks like this:
Sub Test()
Dim SourceRange As Range, InputRange As Range, FindMonth As String
Set InputRange = Worksheets("Summary").Range("A2")
Set SourceRange = Worksheets("Refs").Columns("A:A").Find(InputRange.Value, LookIn:=xlValues)
FindMonth = SourceRange.Address
MsgBox FindMonth
End Sub
Now I want to convert the sub to a UDF. What I created gives me the #VALUE error :confused: . Can anyone tell me why and what I should change?
Function FindMonth(InputRange As Range) As String
With Worksheets("Refs").Columns("A:A")
FindMonth = .Find(InputRange.Value, LookIn:=xlValues).Address
End With
End Function
Thanks a lot for any help!