Hidding colomns according to a condition

K

Khalil Handal

Hi,
A code to hide colomns depending on a certain value:
Hide colomns AI, AJ, AK if cell AJ9="" (empty)
Hide colomns AL, AM, AN if cell AM=""
Hide colomns AO, AP, AQ if cell AP9=""
Hide colomns AR, AS, AT if cell AS9=""

Is it possible?
 
B

Bob Phillips

Columns("AI:AK").Hidden = Range("AJ9").Value = ""
Columns("AL:AN").Hidden = Range("AM9").Value = ""
Columns("AO:AQ").Hidden = Range("AP9").Value = ""
Columns("AR:AT").Hidden = Range("AS9").Value = ""


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
K

Khalil Handal

Is this a calculate vent??? How should I place it so that it works
automatically???
Note: When I run the code manually it works well.
Thanks
 
D

Dave Peterson

If AJ9, AM9, AP9 and AS9 contain formulas, then put the code in the
worksheet_calculate event.

If those cells are changed because of the user's typing, then you could use the
worksheet_Change event.
 

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