Hi all,
I have 3 sheets:
"Input","dataset","Print"
My objective is to input a few data in "input" Column A and run the macro.
If any cell in Column A of "Dataset" = "input" Column A,
it will print out the whole row results to "Print".
I found many examples of copying rows into another sheet,
however, it is mostly all coded based on the cell value.
My cell value will not be constant therefore I want the macro to look based on Column A instead.
Here is how the dataset looks like:
I did some research and i did found a VBA code that works after some modification,
but it is taking too long to search every data in the cells.
It is also looking at a limited range in Column A instead of the whole Column A:
I would appreciate if someone could help me in this!
Many thanks!
I have 3 sheets:
"Input","dataset","Print"
My objective is to input a few data in "input" Column A and run the macro.
If any cell in Column A of "Dataset" = "input" Column A,
it will print out the whole row results to "Print".
I found many examples of copying rows into another sheet,
however, it is mostly all coded based on the cell value.
My cell value will not be constant therefore I want the macro to look based on Column A instead.
Here is how the dataset looks like:
I did some research and i did found a VBA code that works after some modification,
but it is taking too long to search every data in the cells.
It is also looking at a limited range in Column A instead of the whole Column A:
VBA Code:
Sub Copy()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Dim Condition As Worksheet
Set Source = ActiveWorkbook.Worksheets("Dataset")
Set Target = ActiveWorkbook.Worksheets("Print")
Set Condition = ActiveWorkbook.Worksheets("Input")
j = 1 'This will start copying data to Target sheet at row 1
For Each d In Condition.Range("A5:A86")
For Each c In Source.Range("A1:A86")
If d = c Then
Source.Rows(c.Row).Copy Target.Rows(j)
j = j + 1
End If
Next c
Next d
End Sub
I would appreciate if someone could help me in this!
Many thanks!