ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing cells (https://www.excelbanter.com/excel-programming/373070-comparing-cells.html)

dan

Comparing cells
 
-I have 2,000 records in my sheet. Column A has my Model#, Col B has my List
Price, Col C has the Supplier Model#, Col D has the Supplier New List Price.
--I carry only 1,000 of the Supplier's items.
---I want to run through Col C and find the matching record (if there is
one) in Col A and line up the matching records.
----Can anyone help?

Tom Ogilvy

Comparing cells
 
You want to insert "rows" in Columns A and B so they line up with column C?

Each set of data is sorted?

If so


Sub srt()
r = 2
Do While Cells(r, "A") < "" And Cells(r, "C") < ""
If Cells(r, "A") = Cells(r, "C") Then
Else
If Cells(r, "A") < Cells(r, "C") Then
Cells(r, "C").Resize(1, 2).Select
Selection.Insert Shift:=xlDown
Else
Cells(r, "A").Resize(1, 2).Select
Selection.Insert Shift:=xlDown
End If
End If
r = r + 1
Loop
End Sub

will do it I believe.

--
Regards,
Tom Ogilvy



"Dan" wrote in message
...
-I have 2,000 records in my sheet. Column A has my Model#, Col B has my
List
Price, Col C has the Supplier Model#, Col D has the Supplier New List
Price.
--I carry only 1,000 of the Supplier's items.
---I want to run through Col C and find the matching record (if there is
one) in Col A and line up the matching records.
----Can anyone help?




dan

Comparing cells
 
Tom, this worked well. Thank you, I greatly appreciate your help. Dan Belanger.

"Tom Ogilvy" wrote:

You want to insert "rows" in Columns A and B so they line up with column C?

Each set of data is sorted?

If so


Sub srt()
r = 2
Do While Cells(r, "A") < "" And Cells(r, "C") < ""
If Cells(r, "A") = Cells(r, "C") Then
Else
If Cells(r, "A") < Cells(r, "C") Then
Cells(r, "C").Resize(1, 2).Select
Selection.Insert Shift:=xlDown
Else
Cells(r, "A").Resize(1, 2).Select
Selection.Insert Shift:=xlDown
End If
End If
r = r + 1
Loop
End Sub

will do it I believe.

--
Regards,
Tom Ogilvy



"Dan" wrote in message
...
-I have 2,000 records in my sheet. Column A has my Model#, Col B has my
List
Price, Col C has the Supplier Model#, Col D has the Supplier New List
Price.
--I carry only 1,000 of the Supplier's items.
---I want to run through Col C and find the matching record (if there is
one) in Col A and line up the matching records.
----Can anyone help?






All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com