Copy rows from sheet 1 to sheet 2 if rule is met [Solved/Closed]

sierranz 2 Posts Tuesday March 1, 2016Registration date March 3, 2016 Last seen - Mar 1, 2016 at 04:19 AM - Latest reply: sierranz 2 Posts Tuesday March 1, 2016Registration date March 3, 2016 Last seen
- Mar 3, 2016 at 04:17 AM
Hi


I have a contact list I need to extract data from.
Full contact list is sheet 1
Names are in A2:A12948
Internal phone numbers in B2:B12948
DDI numbers in C2:C12948
Mobile numbers in D2:D12948

I would like to copy rows to sheet 2 if there is data in A and D
So users who only list a mobile number will be copied to sheet 2

Thank you
See more 

2 replies

Best answer
TrowaD 2435 Posts Sunday September 12, 2010Registration dateModeratorStatus October 8, 2018 Last seen - Mar 1, 2016 at 11:50 AM
1
Thank you
Hi Sierranz,

The code below will do as requested. Results will be in column A & D of sheet2.

Here is the code:
Sub RunMe()
Sheets("Sheet1").Select

For Each cell In Range("A2:A12948")
    If cell.Value <> vbNullString And _
    cell.Offset(0, 1).Value = vbNullString And _
    cell.Offset(0, 2).Value = vbNullString And _
    cell.Offset(0, 3).Value <> vbNullString Then _
    cell.EntireRow.Copy _
    Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
Next cell

End Sub


Thank you, TrowaD 1

Something to say? Add comment

CCM has helped 1302 users this month

sierranz 2 Posts Tuesday March 1, 2016Registration date March 3, 2016 Last seen - Mar 3, 2016 at 04:17 AM
0
Thank you
Thank you TrowaD that worked great!