Dear all<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I have a code to search range A1:B250, where a user is given the opportunity to search among 250 foundations. The name of the foundation is located in column B, its number in column A. They often contain similar words (letters) and search often return several suggestions. My variable NewRange present the hits, which is forwarded to a ListBox where the user can select the correct one.
My question is if someone can help me to adjust my macro to return not only the name but the corresponding number as well (same row, the cell to left).<o></o>
<o></o>
Best regards
Geir<o></o>
I have a code to search range A1:B250, where a user is given the opportunity to search among 250 foundations. The name of the foundation is located in column B, its number in column A. They often contain similar words (letters) and search often return several suggestions. My variable NewRange present the hits, which is forwarded to a ListBox where the user can select the correct one.
My question is if someone can help me to adjust my macro to return not only the name but the corresponding number as well (same row, the cell to left).<o></o>
Rich (BB code):
Sub Copy_To_Another_Range() 'http://www.rondebruin.nl/find.htm (adjusted)
Rich (BB code):
Rich (BB code):
Dim FirstAddress As String
Dim StrPrompt As String
Dim MyArr As Variant
Dim rng As Range
Dim Rcount As Long
Dim i As Long
Dim NewRange As Range
Rich (BB code):
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
MyArr = Array(InputBox(StrPrompt))
Set NewRange = Sheets("SUMMER konto").Range("M10")
With Sheets("LISTE LEGATER").Range("A1:B300")<o:p></o:p>
Rcount = 0<o:p></o:p>
For i = LBound(MyArr) To UBound(MyArr)<o:p></o:p>
Set rng = .Find(what:=MyArr(i), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
lookat:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
FirstAddress = rng.Address
Do
Rcount = Rcount + 1
rng.Copy NewRange.Range("A" & Rcount)<o:p></o:p>
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.Address <> FirstAddress
End If
Next i
End With<o:p></o:p>
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Call UserForm
End Sub
Best regards
Geir<o></o>
Last edited: