Conditional hide rows macros
What I want to do is:
If data is in a certain cell then I want to unhide a row and if there is nothing in the certain cell then I want the row to be hidden. I understand there is no actual worksheet function to do this but you can use a macro for this. I have no idea about macros which is my only problem with using them. Any suggestions will be useful. Thank you ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
Conditional hide rows macros
Stu
Here's a primer on using VBA in Excel http://www.mvps.org/dmcritchie/excel/getstarted.htm For you particular problem, you need to identify the Range object that is that cell and test its Value property. Based on that test, you would use the EntireRow property to return a Range object that encompasses the entire row and use the Hidden property to hide or unhide it. Here's a basic example If Range("A1").Value = 3 Then Range("A1").EntireRow.Hidden = True Else Range("A1").EntireRow.Hidden = False End If If you want to check a number of cells, you can use a For Each construct to loop through all the cells in a particular range. Here's an example of that Dim Cell as Range For Each Cell in Range("C1:C10").Cells If Cell.Value = 3 Then Cell.EntireRow.Hidden = True Else Cell.EntireRow.Hidden = False End If Next Cell -- Dick Kusleika MVP - Excel www.dicks-clicks.com Post all replies to the newsgroup. "Stu" wrote in message ... What I want to do is: If data is in a certain cell then I want to unhide a row and if there is nothing in the certain cell then I want the row to be hidden. I understand there is no actual worksheet function to do this but you can use a macro for this. I have no idea about macros which is my only problem with using them. Any suggestions will be useful. Thank you ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 07:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com