excel hiddden rows and colums - one last question

N

Nils

I used the following information from
Earl Kiosterud
mvpearl omitthisword at verizon period net
and it is excellent for rows and colums to be hidden if a
value is entered into a cell.

However, one last question, how do I use it together on
the same sheet to hide a row and colum at the same time?

=====================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Set TestCell = Range("J5")
TestValue = "stuff"
If TestCell = TestValue Then
Range("B1").EntireColumn.Hidden = True
Else
Range("B1").EntireColumn.Hidden = False
End If
End Sub
========================================================
 
C

Chip Pearson

Nils,

Try the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim TestCell As Range
Dim TestValue As Variant
Set TestCell = Range("J5")
TestValue = "stuff"
If TestCell = TestValue Then
Range("B1").EntireColumn.Hidden = True
Range("B1").EntireRow.Hidden = True
Else
Range("B1").EntireColumn.Hidden = False
Range("B1").EntireRow.Hidden = False
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 

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