offset range

MetLife

Active Member
Joined
Jul 2, 2012
Messages
330
Office Version
  1. 365
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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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