offset range

MetLife

Active Member
Joined
Jul 2, 2012
Messages
283
Hi I want to do some sorting on ranges and reset the range using offset but it isn't working.

I have a table of data and want to sort/remove duplicates on each column separately. There are about 100 columns.

VBA Code:
Sub Macro1()

    Dim x2 As Range
    Dim y2 As Range
    Dim i As Integer
   
    Set x2 = Range("C2:C100000")
   
For i = 1 To 100
   Set x2 = Range("C2:C100000").Offset(0, i)
    Range(x2).Select
    ActiveSheet.Range(x2).RemoveDuplicates Columns:=1, Header:=xlYes
Next i

End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
How about
VBA Code:
Sub Macro1()

    Dim x2 As Range
    Dim i As Integer
   
    Set x2 = Range("C2:C100000")
   
For i = 1 To 32
    x2.Offset(, i).RemoveDuplicates Columns:=1, Header:=xlYes
Next i

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

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