4
41db14
A while back someone was very helpful in solving a macro problem.
I need a little more assistance. The macro compared "Column A" in two
worksheets (Master & Sub) and identified the duplicates by changing the cell
background to red.. When the macro encountered it's first blank cell in the
Master sheet the macro stopped running. This Macro worked great.
I still need to compare the two worksheets "Column A" but when the macro
sees duplicates it needs to delete the entire row in the Master worksheet.
Below is the Macro I have been using... I am not sure if this macro can be
modified or need a complete new macro? Any assistance would be appreciated.
Sub FindDupes() 'assuming both sheets are in same book and book is open
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim cell1 As Range
Dim cell2 As Range
Dim str As String
str = InputBox("Type name of first sheet")
Set sht1 = Worksheets(str)
str = InputBox("Type name of second sheet")
Set sht2 = Worksheets(str)
For Each cell1 In sht1.Columns(1).Cells
If cell1.Value = "" Then Exit Sub
For Each cell2 In sht2.Columns(1).Cells
If cell2.Value = cell1.Value Then
cell1.Interior.ColorIndex = 3
cell2.Interior.ColorIndex = 3
End If
Next cell2
Next cell1
End Sub
I need a little more assistance. The macro compared "Column A" in two
worksheets (Master & Sub) and identified the duplicates by changing the cell
background to red.. When the macro encountered it's first blank cell in the
Master sheet the macro stopped running. This Macro worked great.
I still need to compare the two worksheets "Column A" but when the macro
sees duplicates it needs to delete the entire row in the Master worksheet.
Below is the Macro I have been using... I am not sure if this macro can be
modified or need a complete new macro? Any assistance would be appreciated.
Sub FindDupes() 'assuming both sheets are in same book and book is open
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim cell1 As Range
Dim cell2 As Range
Dim str As String
str = InputBox("Type name of first sheet")
Set sht1 = Worksheets(str)
str = InputBox("Type name of second sheet")
Set sht2 = Worksheets(str)
For Each cell1 In sht1.Columns(1).Cells
If cell1.Value = "" Then Exit Sub
For Each cell2 In sht2.Columns(1).Cells
If cell2.Value = cell1.Value Then
cell1.Interior.ColorIndex = 3
cell2.Interior.ColorIndex = 3
End If
Next cell2
Next cell1
End Sub