Guys,
I have a wall regarding my Macro. Bascially I have created functions, and the .find function which was previously working, now states type mismatch-specifically vOurResult code at the end is the problem
The whole code is this:
Function TextSearch()
'(ByVal strSearchFor, ByVal Target As Variant)
Sheets("MO Trade List").Select
Dim FoundCell As Range
Dim LastCell As Range
Dim FirstAddr As String
With Range("A2:A13")
Set LastCell = .Cells(.Cells.Count)
End With
Set FoundCell = Range("A2:A13").Find(What:="TCPAM Investments (Cayman) Limited - MENA Equity Fund", AFTER:=LastCell)
'Cells.FindNext(After.ActiveCell).Activate
'Cells.FindPrevious(After.ActiveCell).Activate
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell
End If
Do Until FoundCell Is Nothing
FoundCell.Copy
Range("A20").Select
ActiveSheet.Paste
'If FoundCell. Found Then Do. FindNext(After:=FoundCell)
Set FoundCell = Range("A2:A13").FindNext(AFTER:=FoundCell)
FoundCell.Copy
Range("A21").Select
ActiveSheet.Paste
Set FoundCell = Range("A2:A13").FindNext(AFTER:=FoundCell)
FoundCell.Copy
Range("A22").Select
ActiveSheet.Paste
'Set FoundCell = Range("A2:A13").FindPrevious(After:=FoundCell)
If FoundCell = FirstAddr Then
Exit Do
End If
Loop
'If Not .Found Then Exit Do
'Loop Until Not .Found
End Function
'Fund Name
Function ValueCatching()
Sheets("MO Trade List").Select
Dim Fund1 As String
vOurResult = Cells.Find(What:="TCPAM Investments (Cayman) Limited - MENA Equity Fund", AFTER:=LastCell, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Offset(0, 3)
Please advise?
Thanks
JJ
I have a wall regarding my Macro. Bascially I have created functions, and the .find function which was previously working, now states type mismatch-specifically vOurResult code at the end is the problem
The whole code is this:
Function TextSearch()
'(ByVal strSearchFor, ByVal Target As Variant)
Sheets("MO Trade List").Select
Dim FoundCell As Range
Dim LastCell As Range
Dim FirstAddr As String
With Range("A2:A13")
Set LastCell = .Cells(.Cells.Count)
End With
Set FoundCell = Range("A2:A13").Find(What:="TCPAM Investments (Cayman) Limited - MENA Equity Fund", AFTER:=LastCell)
'Cells.FindNext(After.ActiveCell).Activate
'Cells.FindPrevious(After.ActiveCell).Activate
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell
End If
Do Until FoundCell Is Nothing
FoundCell.Copy
Range("A20").Select
ActiveSheet.Paste
'If FoundCell. Found Then Do. FindNext(After:=FoundCell)
Set FoundCell = Range("A2:A13").FindNext(AFTER:=FoundCell)
FoundCell.Copy
Range("A21").Select
ActiveSheet.Paste
Set FoundCell = Range("A2:A13").FindNext(AFTER:=FoundCell)
FoundCell.Copy
Range("A22").Select
ActiveSheet.Paste
'Set FoundCell = Range("A2:A13").FindPrevious(After:=FoundCell)
If FoundCell = FirstAddr Then
Exit Do
End If
Loop
'If Not .Found Then Exit Do
'Loop Until Not .Found
End Function
'Fund Name
Function ValueCatching()
Sheets("MO Trade List").Select
Dim Fund1 As String
vOurResult = Cells.Find(What:="TCPAM Investments (Cayman) Limited - MENA Equity Fund", AFTER:=LastCell, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Offset(0, 3)
Please advise?
Thanks
JJ