I'm having some trouble making the below code "find" the cells unless I have the location of the data as the active sheet. I need to be on a blank page and bring the rows over onto that page from a seperate sheet.
Private Sub ComboBox1_DropButt*******()
Dim Found As Range, FirstFound As String, AllRows As Range
If ComboBox1.Value <> vbNullString Then
Set Found = ActiveSheet.Cells.Find(ComboBox1.Value, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Found Is Nothing Then
MsgBox "No match found.", vbCritical, "No Match"
Else
FirstFound = Found.Address
Set AllRows = Found.EntireRow
Do
Set Found = Cells.FindNext(Found)
Set AllRows = Union(AllRows, Found.EntireRow)
Loop Until Found.Address = FirstFound
AllRows.Copy
Sheets("Risk").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial
End If
End If
End Sub
Private Sub ComboBox1_DropButt*******()
Dim Found As Range, FirstFound As String, AllRows As Range
If ComboBox1.Value <> vbNullString Then
Set Found = ActiveSheet.Cells.Find(ComboBox1.Value, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Found Is Nothing Then
MsgBox "No match found.", vbCritical, "No Match"
Else
FirstFound = Found.Address
Set AllRows = Found.EntireRow
Do
Set Found = Cells.FindNext(Found)
Set AllRows = Union(AllRows, Found.EntireRow)
Loop Until Found.Address = FirstFound
AllRows.Copy
Sheets("Risk").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial
End If
End If
End Sub