Copy rows based on a condition

Solved/Closed
Blossom83 - Oct 14, 2008 at 12:53 PM
ravichennai86
Posts
1
Registration date
Wednesday December 12, 2018
Status
Member
Last seen
December 12, 2018
- Dec 12, 2018 at 08:00 AM
Hi

How can I have excel copy the entire row of data from worksheet Employee Inventory to another worksheet called EEs if column Q contains TERM. I've tried almost everything but nothing is working. Please help!

8 replies

Assumptions for this code:
1. Employee Inventory sheet has heading in row one so it will start checking the data in row 2.
2. Column Q does not have any empty cells.
3. EEs sheet will have headings in row one so the data will start copying in row 2.

Set I = Sheets("Employee Inventory")
Set e = Sheets("EEs")
Dim d
Dim j
d = 1
j = 2

Do Until IsEmpty(i.Range("Q" & j))

    If i.Range("Q" & j) = "TERM" Then
    d = d + 1
    e.Rows(d).Value = i.Rows(j).Value
    
    End If
    j = j + 1
Loop
91
Thanks! That is really helpful to me as well.
Just one more thing: How is it possible to copy data always on the fist empty row on the correspondant sheet (here EES sheet), if this sheet can contain altering number of rows time by time.

Thanks,
Anne
0
i am using the same code but nothing seems to be happening, am i missing some step, do i need do anything to run this code
0
Hi,
I am trying to use this code but its giving me error as Object defined error at do loop.
Can you please help me out
0
This is my code

Sub search()

Dim hospital_Name As String
hospital_Name = Range("B3").Value
Set I = Sheets("Regional Data")
Set e = Sheets("Front")
Dim d
Dim j
d = 16
j = 1

Do Until IsEmpty(i.Range("HOSPITAL NAME" & j))

If i.Range("HOSPITAL NAME" & j) = hospital_Name Then
d = d + 1

e.Rows(d).Value = i.Rows(j).Value

End If
j = j + 1
Loop
End Sub
0
Without trying to sound like an ignoramus, where do you type in this code?
0