referring to a row that contains a single cell

P

Paul

I would like to write VBA code to hide an entire row which contains a single
cell named "MyCell." That is, I don't know which row MyCell" will be in,
but whatever row it's in, that's the row I want to hide.

The sheet will always be the ActiveSheet. How can I write a line of code
that will hide the row that "MyCell" is in?

Thanks in advance,

Paul
 
D

dmoney

Cells.Select
Selection.Find(What:="hat", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Select
Selection.EntireRow.Hidden = True
 
D

Don Guillett

One of us mis-interpreted the question. If you are right, this is a bit
simpler if the word is in the cell by itself.

Sub HiderowifWHOLEtext()
cells.Find(What:="mycell", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False) _
.EntireRow.Hidden = True
End Sub
 
P

Paul

Don, dmoney,

Don had it right the first time - the cell in question has the Range name of
"MyCell." I tested the suggested solution,
"Range("MyCell").EntireRow.Hidden = True" and it works just fine.

Thanks so much for responding to my question, and for providing a solultion.

Paul
 

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