ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If function with two results required (https://www.excelbanter.com/excel-worksheet-functions/139770-if-function-two-results-required.html)

Loretta

If function with two results required
 
I'm using Excel 2003, have a workbook with multiple linked tabs and one page
(printout tab), I want to hide rows with no data automatically (not manually).

Currently using this function: =IF('Bid Form'!B16=0,"",'Bid Form'!$A16 &"A")
Can I substitute the "" with some command to make it hide the entire row
(when B16=0)??
--
Thanks for your help!
Loretta

JE McGimpsey

If function with two results required
 
No, functions can only return values to their calling cells, they can't
format/hide/etc.

You could use an event macro to do this automatically. Put something
like this in your worksheet code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Calculate()
Dim rCell As Range
On Error GoTo ErrHandler
Application.EnableEvents = False
For Each rCell In Range("B2:B" & Range("B" & _
Rows.Count).End(xlUp).Row)
With rCell
.EntireRow.Hidden = (.Value = vbNullString)
End With
Next rCell
ErrHandler:
Application.EnableEvents = True
End Sub

In article ,
Loretta wrote:

I'm using Excel 2003, have a workbook with multiple linked tabs and one page
(printout tab), I want to hide rows with no data automatically (not manually).

Currently using this function: =IF('Bid Form'!B16=0,"",'Bid Form'!$A16 &"A")
Can I substitute the "" with some command to make it hide the entire row
(when B16=0)??


Loretta

If function with two results required
 
I think this is going to work.. will need to tweak a little to do line by line
--
Thanks for your help!
Loretta


"JE McGimpsey" wrote:

No, functions can only return values to their calling cells, they can't
format/hide/etc.

You could use an event macro to do this automatically. Put something
like this in your worksheet code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Calculate()
Dim rCell As Range
On Error GoTo ErrHandler
Application.EnableEvents = False
For Each rCell In Range("B2:B" & Range("B" & _
Rows.Count).End(xlUp).Row)
With rCell
.EntireRow.Hidden = (.Value = vbNullString)
End With
Next rCell
ErrHandler:
Application.EnableEvents = True
End Sub

In article ,
Loretta wrote:

I'm using Excel 2003, have a workbook with multiple linked tabs and one page
(printout tab), I want to hide rows with no data automatically (not manually).

Currently using this function: =IF('Bid Form'!B16=0,"",'Bid Form'!$A16 &"A")
Can I substitute the "" with some command to make it hide the entire row
(when B16=0)??




All times are GMT +1. The time now is 06:04 PM.

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