Let me try a different tact...
Basically this macro works but so far not able to get this to append when activating this line:
'Set wsDest = ActiveWorkbook.Worksheets("Sheet2")
While deactivating this line:
Set wsDest = ActiveWorkbook.Worksheets.Add
Currently the macro adds a new worksheet each time the macro is run and valid search criteria is input.
It also will only search within the active worksheet. To avoid running through "Many" spreadsheets per workbook.
Would be great if it search the entire workbook. doable?
Sub Key_Word_Search()
Dim Ret_type As Integer
Dim strMsg As String
Dim strTitle As String
Dim myValue As Variant
' Dialog Message
strMsg = "Search current Worksheet?"
' Dialog's Title
strTitle = "Search WorkSheet"
'Display MessageBox
Ret_type = MsgBox(strMsg, vbYesNoCancel + vbQuestion, strTitle)
' Check pressed button
Select Case Ret_type
Case 6
myValue = strTest
strTest = InputBox("Your Search Criteria?")
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim NoRows As Long
Dim DestNoRows As Long
Dim i As Long
Dim rngCells As Range
Dim rngFind As Range
Set wsSource = ActiveSheet
NoRows = wsSource.Range("A65536").End(xlUp).Row
DestNoRows = 2
Set wsDest = ActiveWorkbook.Worksheets.Add
'Set wsDest = ActiveWorkbook.Worksheets("Sheet2")
For i = 1 To NoRows
Set rngCells = wsSource.Range("D" & i & ":F" & i)
If Not (rngCells.Find(strTest) Is Nothing) Then
rngCells.EntireRow.Copy wsDest.Range("A" & DestNoRows)
DestNoRows = DestNoRows + 1
End If
Next i
Case 7
MsgBox "Click ok Search again"
Call Key_Word_Search
Case 2
MsgBox "Quit?"
End Select
End Sub
Sub Choose()
Dim Ret_type As Integer
Dim strMsg As String
Dim strTitle As String
' Dialog Message
strMsg = "Click any one of the below buttons."
' Dialog's Title
strTitle = "Search for Morgan WorkSheets"
'Display MessageBox
Ret_type = MsgBox(strMsg, vbYesNoCancel + vbQuestion, strTitle)
' Check pressed button
Select Case Ret_type
Case 6
MsgBox "You clicked 'YES' button."
Case 7
MsgBox "You clicked 'NO' button."
Case 2
MsgBox "You clicked 'CANCEL' button."
End Select
End Sub
Bookmarks