Hide Rows if cell value is

  • Thread starter mohd21uk via OfficeKB.com
  • Start date
M

mohd21uk via OfficeKB.com

I would like to hide a row if certain values are entered in three cells. For
e.g. if United Kingdom is selected in Cell C3 and C5 and CI is selected from
cell C10, I would then have Row 16 hidden. I would like this to be
dynamically i.e. updated whenever the value in the cell changes.

Many thanks in advance.
 
N

Norman Jones

Hi Mohd,

Try:

'=============>>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

Set rng = Me.Range("C3,C5,C10")

If Not Intersect(rng, Target) Is Nothing Then
Rows(16).EntireRow.Hidden = Range("C3").Value = _
"United Kingdom" And Range("C5").Value = _
"United Kingdom" And Range("C10") = "C1"
End If
End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top