Comparing 1 value with two other columns Loop

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
 
They don't duplicate because Either column "D" or "E" is empty.
names in A are different from either D or E and the cells aren't empty

What is the actual requirement for empty cells
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top