Hiding rows

  • Thread starter Thread starter Lacy
  • Start date Start date
L

Lacy

Is it possible to hide or delete a row using a formula?
For an example if row1 reads Betty Sowers and row2 reads
Betty Sowers, I want to get rid of the dupicates.

Thanks,
Lacy
 
Is there a way to do it with a macro that automatically
executes when you open the template?

Thanks,
Lacy
 
Lacy,
You might try this.
Assuming that column A has no blank rows and that column A
has the duplicate entries for which you are searching,
copy the following code into a module.

Sub HideDupes()

Dim NumRows As Double
Dim DupeCheck As String
Dim I As Double

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells
(xlLastCell)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("A1").Select
DupeCheck = ActiveCell
Range("A2").Select
NumRows = Cells(1, 1).End(xlDown).Row
For I = 1 To NumRows - 1
If DupeCheck = ActiveCell Then
Selection.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Select
Else
DupeCheck = ActiveCell
ActiveCell.Offset(1, 0).Select
End If
Next I
End

Then post this routine into "ThisWorkbook", not into a
separate module.

Private Sub Workbook_open()
HideDupes
End Sub

The routine directly above tells Excel to run
the "HideDupes" routine upon opening.

The "HideDupes" routine will sort the worksheet based on
column A and will then hide the duplicate rows.

Hpoe this helps.
 
Back
Top