Thread: [Solved] Help please
View Single Post
 
Old 12-15-2017, 04:39 PM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 587
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Here is a macro method. Paste this macro into a Routine Module. Run from Command Button on Sheet 1 :

Code:
Option Explicit

Sub CopyYes()
    Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target As Worksheet
    
    Dim myString As String

    ' Change worksheet designations as needed
    Set Source = ActiveWorkbook.Worksheets("Sheet1")
    Set Target = ActiveWorkbook.Worksheets("Sheet2")
    
    myString = Application.InputBox("Enter A Search Term")
    
    j = 2     ' Start copying to row 1 in target sheet
    For Each c In Source.Range("B1:B1000")   ' Do 1000 rows
        If c = myString Then
           Source.Rows(c.Row).Copy Target.Rows(j)
           j = j + 1
        End If
    Next c
End Sub
Reply With Quote