ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   referring to a row that contains a single cell (https://www.excelbanter.com/excel-programming/428966-referring-row-contains-single-cell.html)

Paul

referring to a row that contains a single cell
 
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



Don Guillett

referring to a row that contains a single cell
 
Sub hidenamedcellrow()
Range("MyCell").EntireRow.Hidden = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Paul" wrote in message
...
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



DMoney

referring to a row that contains a single cell
 
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



"Paul" wrote:

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




Don Guillett

referring to a row that contains a single cell
 
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 Guillett
Microsoft MVP Excel
SalesAid Software

"dmoney" wrote in message
...
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



"Paul" wrote:

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





Paul

referring to a row that contains a single cell
 
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



Don Guillett

referring to a row that contains a single cell
 
Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Paul" wrote in message
...
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




All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com