Code:
Sub testPalLIne()
'JIL
Call TestFindAll("Pal Line 1")
End Sub
I have this code below find first the Pal Line then next transaction but I cannot terminate adding of transaction until Found cells for Pal Line is not equal to the combo value..please help..
Code:
Public Sub TestFindAll(cmbValue As Variant)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TestFindAll
' This is a test procedure for FindAll.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim SearchRange As Range
Dim FoundCells As Range
Dim FoundCell As Range
Dim FindWhat As Variant
Dim MatchCase As Boolean
Dim LookIn As XlFindLookIn
Dim LookAt As XlLookAt
Dim SearchOrder As XlSearchOrder
Dim SearchRange1 As Range
Dim FoundCells1 As Range
Dim FoundCell1 As Range
Dim FindWhat1 As Variant
Dim MatchCase1 As Boolean
Dim LookIn1 As XlFindLookIn
Dim LookAt1 As XlLookAt
Dim SearchOrder1 As XlSearchOrder
''''''''''''''''''''''''''
'Find First All Pal Line
'''''''''''''''''''''''''''
Set SearchRange = Sheet17.Range("A4:IV4")
FindWhat = "Pal"
LookIn = xlValues
LookAt = xlPart
SearchOrder = xlByColumns
MatchCase = False
'''''''''''''''''''
' Search the range.
'''''''''''''''''''
Set FoundCells = FindAll(SearchRange:=SearchRange, FindWhat:=FindWhat, _
LookIn:=LookIn, LookAt:=LookAt, SearchOrder:=SearchOrder, MatchCase:=MatchCase)
''''''''''''''''''''''''''
'Second Find All Transaction
'''''''''''''''''''''''''''
Set SearchRange1 = Sheet17.Range("A4:IV4")
FindWhat1 = "Transaction"
LookIn1 = xlValues
LookAt1 = xlPart
SearchOrder1 = xlByColumns
MatchCase1 = False
'''''''''''''''''''
' Search the range.
'''''''''''''''''''
Set FoundCells1 = FindAll2(SearchRange:=SearchRange1, FindWhat:=FindWhat1, _LookIn:=LookIn1, LookAt:=LookAt1, SearchOrder:=SearchOrder1, MatchCase:=MatchCase1)
''''''''''''''''''''''
' Display the results.
''''''''''''''''''''''
For Each FoundCell In FoundCells.Cells 'Find Pal lines
If FoundCell.Text = cmbValue Then ' If Found cell equal to comboValue
For Each FoundCell1 In FoundCells1.Cells 'Find All Transactions
Do
ActiveSheet.ComboBox2.AddItem FoundCell1.Text
Loop Until (FoundCell <> cmbValue) 'Add Transaction Until Find Pal Lines not equal to cmbValue
Next FoundCell1
End If
Next FoundCell
End Sub