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!!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,541
Latest member
iparraguirre89

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