I3atnumb3rs
New Member
- Joined
- Nov 2, 2018
- Messages
- 34
Hello,
I'm trying to create a loop that checks the names in column A with the names in column D and E. If The names in A are different from either D or E and the cells aren't empty I want to duplicate the line. I got the line duplicating, but it's not ignoring empty cells and duplicating anyway. Please help!
Sub DiffNames()
'Loop trough rows, if D != E create a new lines
Application.ScreenUpdating = False
Dim lngRow As Long
Dim Number
With ActiveSheet
lngRow = .Cells(65536, 1).End(xlUp).Row
Do
If IsEmpty(.Cells(lngRow, 4)) = False And _
IsEmpty(.Cells(lngRow, 5)) = False And _
.Cells(lngRow, 1) <> .Cells(lngRow, 4) = True Or _
.Cells(lngRow, 1) <> .Cells(lngRow, 5) = True Then
.Cells(lngRow, 1).EntireRow.Select
Selection.EntireRow.Copy
Selection.EntireRow.Insert Shift:=xlDown
End If
lngRow = lngRow - 1
Loop Until lngRow = 1
End With
End Sub
I'm trying to create a loop that checks the names in column A with the names in column D and E. If The names in A are different from either D or E and the cells aren't empty I want to duplicate the line. I got the line duplicating, but it's not ignoring empty cells and duplicating anyway. Please help!
Sub DiffNames()
'Loop trough rows, if D != E create a new lines
Application.ScreenUpdating = False
Dim lngRow As Long
Dim Number
With ActiveSheet
lngRow = .Cells(65536, 1).End(xlUp).Row
Do
If IsEmpty(.Cells(lngRow, 4)) = False And _
IsEmpty(.Cells(lngRow, 5)) = False And _
.Cells(lngRow, 1) <> .Cells(lngRow, 4) = True Or _
.Cells(lngRow, 1) <> .Cells(lngRow, 5) = True Then
.Cells(lngRow, 1).EntireRow.Select
Selection.EntireRow.Copy
Selection.EntireRow.Insert Shift:=xlDown
End If
lngRow = lngRow - 1
Loop Until lngRow = 1
End With
End Sub