Hide row if

bouncey

New Member
Joined
Jan 13, 2010
Messages
35
Hi there,

I have sheet which I add to daily. When I enter data into any cell in column A I need to know if there is already an identical entry. Also I would like to search through column H, if a cell is populated I would like to hide that row.

All help to put the above into a macro would be most appreciated
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Your parameters for executing the code are very cloudy so I made a bunch of assumptions but here you go.

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lastrow As Long, hlastrow As Long
Dim iFind As Range, icell As Range
 
lastrow = Range("A" & Rows.Count).End(xlUp).Row
hlastrow = Range("H" & Rows.Count).End(xlUp).Row
 
'Finds if there is a duplicate in column A and alerts you to its location by a message box
If Not Intersect(Target, Range("A1:A" & lastrow + 1)) Is Nothing Then
    Set iFind = Range("A1:A" & lastrow - 1).Find(What:=Target.Value, After:=Range("A1"), LookIn:=xlValues, Lookat:=xlWhole)
    If Not iFind Is Nothing Then
        MsgBox ("There is a duplicate entry at " & iFind.Address)
    End If
'Searches through column H for any value and if true hides that entire row
For Each icell In Range("H1:H" & hlastrow)
    If Not IsEmpty(icell) Then
        icell.EntireRow.Hidden = True
    End If
Next icell
 
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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