Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have the following code below. How can I include sheet "customers2" also in
the code? Private Sub CommandButton99_Click() Dim iRow As Long Dim FirstRow As Long Dim LastRow As Long With Worksheets("Customers") FirstRow = 2 'headers in row 1 LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For iRow = FirstRow To LastRow Step 1 If Application.CountIf(.Range("a1").EntireColumn, _ .Cells(iRow, "A").Value) 1 Then 'it's a duplicate .Rows(iRow).Delete End If Next iRow End With Unload Me End Sub thank you -- kk |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
One way:
Option Explicit Private Sub CommandButton99_Click() Dim iRow As Long Dim FirstRow As Long Dim LastRow As Long Dim wks As Worksheet For Each wks In Worksheets(Array("customers", "customers2")) With wks FirstRow = 2 'headers in row 1 LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For iRow = FirstRow To LastRow Step 1 If Application.CountIf(.Range("a1").EntireColumn, _ .Cells(iRow, "A").Value) 1 Then 'it's a duplicate .Rows(iRow).Delete End If Next iRow End With Next wks Unload Me End Sub kk wrote: I have the following code below. How can I include sheet "customers2" also in the code? Private Sub CommandButton99_Click() Dim iRow As Long Dim FirstRow As Long Dim LastRow As Long With Worksheets("Customers") FirstRow = 2 'headers in row 1 LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For iRow = FirstRow To LastRow Step 1 If Application.CountIf(.Range("a1").EntireColumn, _ .Cells(iRow, "A").Value) 1 Then 'it's a duplicate .Rows(iRow).Delete End If Next iRow End With Unload Me End Sub thank you -- kk -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Dave that works.
-- kk "Dave Peterson" wrote: One way: Option Explicit Private Sub CommandButton99_Click() Dim iRow As Long Dim FirstRow As Long Dim LastRow As Long Dim wks As Worksheet For Each wks In Worksheets(Array("customers", "customers2")) With wks FirstRow = 2 'headers in row 1 LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For iRow = FirstRow To LastRow Step 1 If Application.CountIf(.Range("a1").EntireColumn, _ .Cells(iRow, "A").Value) 1 Then 'it's a duplicate .Rows(iRow).Delete End If Next iRow End With Next wks Unload Me End Sub kk wrote: I have the following code below. How can I include sheet "customers2" also in the code? Private Sub CommandButton99_Click() Dim iRow As Long Dim FirstRow As Long Dim LastRow As Long With Worksheets("Customers") FirstRow = 2 'headers in row 1 LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For iRow = FirstRow To LastRow Step 1 If Application.CountIf(.Range("a1").EntireColumn, _ .Cells(iRow, "A").Value) 1 Then 'it's a duplicate .Rows(iRow).Delete End If Next iRow End With Unload Me End Sub thank you -- kk -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
delete duplicates in column not the row | Excel Discussion (Misc queries) | |||
How to delete duplicates between workbooks? | Excel Worksheet Functions | |||
Delete Duplicates | New Users to Excel | |||
combine row and the delete duplicates | Excel Discussion (Misc queries) | |||
Delete duplicates | Excel Worksheet Functions |