Matching Columns - Help

  • Thread starter Thread starter bmatthews
  • Start date Start date
B

bmatthews

I am needing to match up a set of columns to an existing column.
:confused:

Every time I put together this report I have to manually match column
"A" (which is numbered 2-668), to column "B" (which is numbered 2-668
with missing random rows)

I need excel to take column "B" and match it to column "A"

If I have 1,2,3,4,5 going down column "A", how do I get column "B" to
match row by row, inserting the blank rows where needed, when column
"B" only has 1,3, & 5?
 
bmatthews,

Try the sub below.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim i As Integer

Range("B2", Range("B65536").End(xlUp)).Sort _
Key1:=Range("B1"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom

For i = 2 To Range("A65535").End(xlUp).Row - 1
If Cells(i, 2).Value <> Cells(i, 1) Then
Cells(i, 2).Insert shift:=xlDown
End If
Next i

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top