New to VBA: remove multiple entries in a dynamic range

hamidpatel

New Member
Joined
Jan 17, 2018
Messages
2
Hi all,

I'm very new to VBA.

I'm trying to copy a one month data (let's name this Workbook A) and paste it on a compiled workbook of monthly data (Workbook B).

So I'm trying to figure out how to remove duplicate entries of monthly data in Workbook B, while at the same time making the data range in Workbook B dynamic.

What I have now is this:

Code:
Sub remove_duplicate()
'
' remove_duplicate Macro
'
    Range("A1").Select
    Selection.CurrentRegion.Select
    ActiveSheet.Range("$A$1:$G$3436").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6 _
        , 7), Header:=xlYes
End Sub

I know that Range("$A$1:$G$3436) is not dynamic and it will be problematic as I add next month's data.

Another question is can somebody explain how the Columns and Array work?

Thanks a lot in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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