Alter macro to allow for dynamic range

rebubula

New Member
Joined
Dec 20, 2010
Messages
26
Hi. I recorded this macro in Excel and need to change the range to allow for a variable amount of rows.

Sub PasteSpecialRemoveDups()
'
' PasteSpecialRemoveDups Macro
'

'
Sheets("1_Vendor_Upload").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("2_Lines").Select
Cells.Select
Range("A34").Activate
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("3_Parts_Info_Brand").Select
Cells.Select
Range("A34").Activate
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("4_Vendor_Brand").Select
Cells.Select
Range("A37").Activate
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("5_Product_Line_Catalog_Type").Select
Cells.Select
Range("A37").Activate
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("6_Product_Lines_Catalog").Select
Cells.Select
Range("A35").Activate
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("7_Vendor_Catalogs").Select
Cells.Select
Range("A40").Activate
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("8_Vendor_Users").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("9_Parts").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("1_Vendor_Upload").Select
Cells.Select
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$D$73").RemoveDuplicates Columns:=Array(1, 2, 3, 4), _
Header:=xlNo
Sheets("2_Lines").Select
Cells.Select
Range("A34").Activate
ActiveSheet.Range("$A$1:$C$73").RemoveDuplicates Columns:=Array(1, 2, 3), _
Header:=xlYes
ActiveWindow.SmallScroll Down:=-3
Sheets("3_Parts_Info_Brand").Select
Cells.Select
Range("A34").Activate
ActiveSheet.Range("$A$1:$B$73").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheets("4_Vendor_Brand").Select
Cells.Select
Range("A37").Activate
ActiveSheet.Range("$A$1:$B$73").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheets("5_Product_Line_Catalog_Type").Select
Cells.Select
Range("A37").Activate
ActiveSheet.Range("$A$1:$B$73").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheets("6_Product_Lines_Catalog").Select
Cells.Select
Range("A35").Activate
ActiveSheet.Range("$A$1:$F$73").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6) _
, Header:=xlYes
Sheets("7_Vendor_Catalogs").Select
Cells.Select
Range("A40").Activate
ActiveSheet.Range("$A$1:$B$73").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheets("8_Vendor_Users").Select
Cells.Select
ActiveSheet.Range("$A$1:$B$11").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheets("9_Parts").Select
Cells.Select
ActiveSheet.Range("$A$1:$P$240").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, _
7, 8, 9, 10, 11, 12, 13, 14, 15, 16), Header:=xlYes
End Sub

Thanks in advance!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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