Editing macro to allow dynamic ranges

rebubula

New Member
Joined
Dec 20, 2010
Messages
26
Hi-

I am really new to macros and am having trouble editing the code to allow for dynamic ranges. I have tried to research online, but am having a hard time with it. I think I would understand better if I could see a practical example.

Here is the sample macro I recorded in Excel that I am working with:

Sub Macro1()
'
' Macro1 Macro
'

'
Cells.Select
ActiveSheet.Range("$A$1:$C$87").RemoveDuplicates Columns:=Array(1, 2, 3), _
Header:=xlNo
End Sub

How can I edit this to allow for dynamic rows and columns?

Thanks in advance!!
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,889
This will select the entire filled region contiguous to A1

ActiveSheet.Range("A1").CurrentRegion.Select


This will include columns A:C for as many rows as is in column A

ActiveSheet.Range("A1:C" & Cells(Rows.Count, 1).End(xlUp).Row).Select
 

Watch MrExcel Video

Forum statistics

Threads
1,127,336
Messages
5,624,093
Members
416,011
Latest member
chengkoonwing

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
Top