Shift Down if not match

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
Hi,
I have data from A2:G2 to A4000:G4000

so I am matching column A with column B

if cells in Column B don't match with cells in Column A than Shift down cells B:G and check if tht matches if tht matchs and check the next row and repeat

I don't want to spend hours doing it manually plz help me

Thanks
 
I fixed the code bit. It will work both ways.

This code is Comparing Column A with column C.

If A & C don't match it will check which one is greater.

It can shift down both column A & B and also C & D.

Code:
Sub AlignData()
Dim LR As Long, i As Long
Dim IFind As Variant, IFind2 As Variant
'this compares two columns (A, E) to align matching data to same row
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
i = 2
Do
IFind = Cells(i, 1)
IFind2 = Cells(i, 3)
If IFind < IFind2 Then
If IFind <> IFind2 Then
Range(Cells(i, 3), Cells(i, 4)).Insert Shift:=xlDown
End If
ElseIf IFind > IFind2 Then
If IFind2 <> IFind Then
Range(Cells(i, 1), Cells(i, 2)).Insert Shift:=xlDown
End If
End If
i = i + 1
     
   
Loop Until IsEmpty(Cells(i, 1))
      
MsgBox "Done"
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I need to do exactly what the original poster is trying to do. Where is the code in the solution entered?
 
Upvote 0

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