referring to a row that contains a single cell

  • Thread starter Thread starter Paul
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top