I've been playing around with this rather excellent Find Function and the following sub. The sub kind of does what i want though it is too specific, basically i want to allow a user to put a figure into, say G1 then run the sub. This will search based upon what is in G1. Any idea how i modify it to do this?
Thanks
Thanks
Rich (BB code):
Function Find_Range(Find_Item As Variant, _
Search_Range As Range, _
Optional LookIn As Variant, _
Optional LookAt As Variant, _
Optional MatchCase As Boolean) As Range
Dim c As Range
If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas
If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole
If IsMissing(MatchCase) Then MatchCase = False
With Search_Range
Set c = .Find( _
What:=Find_Item, _
LookIn:=LookIn, _
LookAt:=LookAt, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MatchCase, _
SearchFormat:=False)
If Not c Is Nothing Then
Set Find_Range = c
firstAddress = c.Address
Do
Set Find_Range = Union(Find_Range, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Function
Sub Code:
I've tried changing "ben" to G1 but this doesn't work, i tried G1 and "G1"
Rich (BB code):
Sub Ex_1()
Find_Range("ben", Range("B:B")).Select
Selection.Font.Bold = True
End Sub
Last edited: