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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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