Hiding Rows/Columns

K

Kevin

I need some help writing some code to hide entire rows and
columns based upon values of cells. I have about 1000
rows and about 25 columns to check to see if the columns
or row should be displayed or hidden.
For example if z10 = "xxx" I'd like to hide the entire
row from view
then check z11 = "xxx" and hide that row and so on for
about 1000 rows
I'd need the same type of loopin code for my 25 columns.
Values change in all the cells, so there may be times
where the cells contain data and I'd want the row to be
displayed. Other times there won't be data and I just
want to hide that row. This way only the row/column
combinations that have the data I want to see will be
displayed.
thanks.
 
B

Bernie Deitrick

Kevin,

This sounds like a job for.......Filtering.


Select a single cell in your table and then start your macro recorder.

Select Data | Filter | AutoFilter. Select the dropdown at the top of column
Z, and choose Custom, then "Does not Equal" in the left dropdown, and but
xxx into the right dropdown. Repeat ad naseum until you have change all
columns to your liking.

Stop the macro recorder, and edit your code by changing the top line from
something like

Selection.AutoFilter

to

Range("A2").CurrentRegion.Select
Selection.AutoFilter

HTH,
Bernie
MS Excel MVP
 

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