hiding select rows in sheets

R

Roger on Excel

I utilise a number of rows into which I place the steps of a chemical process.

The rows for the chemical steps are between row 20 and 87.

I enter a chemical process which takes a number of these rows to complete. I
then have to manually hide the unused rows as they are not required for
printing and for getting to other rows below row 87.

Is there a macro/code I can use which will check for empty cells in column B
(where the process is entered) in rows 20-87 so that these rows will be
automatically hidden. I already have a macro to unhide these cells.

I would need the code to work in any selected sheet as the chemical process
stages may be entered over 10 different sheets (St1, St2, St3 etc).

can anyone help?
 
M

Mike H

Hi,

Put this in a general module, it works on the active sheet. Note that
isempty means exactly that, a formula that returns Null isn't empty.

Sub stance()
Dim MyRange As Range
Set MyRange = ActiveSheet.Range("B20:B87")
For Each c In MyRange
If IsEmpty(c) Then
c.EntireRow.Hidden = True
End If
Next
End Sub

Mike
 
R

Roger on Excel

Thanks Mike,

Roger

Mike H said:
Hi,

Put this in a general module, it works on the active sheet. Note that
isempty means exactly that, a formula that returns Null isn't empty.

Sub stance()
Dim MyRange As Range
Set MyRange = ActiveSheet.Range("B20:B87")
For Each c In MyRange
If IsEmpty(c) Then
c.EntireRow.Hidden = True
End If
Next
End Sub

Mike
 

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