Code to sort rows getting hung up by merged cells

K

kardifflad

Hi. I have two bits of code that are getting hung on the merged cells
have in rows 1, 2 and 3. I need to keep the merged cells so i need th
following two bits of code to ignore these rows. Does anyone have an
ideas please? (and thank you in advance).

' this first bit gets rid of any duplicate rows.

Sub Getridof()

Dim mc As Long
Dim i As Long

mc = 1 'column A
Columns(mc).Sort Key1:=Cells(1, mc), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False
Orientation:=xlTopToBottom
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i).Delete
Next i

End Sub

' this bit is meant to sort column C into order.

Range("C3").Sort Key1:=Range("C3"), Order1:=xlAscending, OrderCustom:=1
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


Thanks
 

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

Top