Conditionally hide a cell

  • Thread starter Thread starter JeffH
  • Start date Start date
J

JeffH

I have a report where by I want to hide some information in certain cells if
the number of employees in the report fall below a certain number (i.e. 25
employess).

I have personal health information (PHI) that I don't want to display/print
in a report if there are less than 25 employees.

How might I do this?
 
JeffH said:
I have a report where by I want to hide some information in certain cells
if
the number of employees in the report fall below a certain number (i.e. 25
employess).

I have personal health information (PHI) that I don't want to
display/print
in a report if there are less than 25 employees.

If you have the total number of employees in a variable intTotalEmployees
and the PHI in a Text Box txtPHI, in the Print event of the section where
txtPHI resides, the following code should do it:

If intTotalEmployees < 25 Then txtPHI.Visible = False Else txtPHI.Visible
= True

You can set the intTotalEmployees with a Domain Aggregate Function DCount on
the Field used to identify employees.

Larry Linson
Microsoft Office Access MVP
 
I'm sorry, I didn't realize this was submitted as an Access question. My
report is in Excel. The number of employees is in a cell. Given a number in
this cell less than 25, I would like to hide some cells in the particular
spreadsheet. I thought I might be able to do this with conditional
formatting.

Then I would like to unhide the cells the next time the report prints for
another employer assuming the employee count is over 24.

I have a macro with some vb code that has a loop and re-prints the report
based upon a list of employers on a separate worksheet. Once the macro
reaches the end of the list it stops printing. This works fine, I just want
to hide some cells for the smaller employers (under 24 employees).

Let me know if I should repost my question under the Excel questions.
 

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

Back
Top