EDIT: Solution in the comments.
Hello all, I really hate to ask this but I've been looking at this all day and am not fluent in VBA and all my attempts result in having to force end Excel and a Macro-Enabled file that I cannot interact with in any way. I need some assistance!
What I'm looking at is trying to hide specific rows based on the values present in two other cells. Hopefully there should be an image attached within this post to accompany the following explanation.
Rundown: Cell B3 has two answers "Yes" or "No" chosen from a drop down list. Cell B4 has 3 options from a drop down list (different types of property). If "Yes" is chosen in B3 then I don't want any row hiding to be performed, everything is fine as is. If "No" is chosen in B3 then I want specific groups of rows to be hidden based on the answer chosen in cell B4, with each property type having it's own group of rows to be hidden. I am uncertain how to accomplish this.
From my research I came across a tutorial that seemed to teach what I wanted - but when I tried applying my own ranges and functions it does not work and my worksheet becomes 'inoperable'. I'll save a Macro-Enabled copy to my computer but upon trying to close the document the software freezes and I have to force end it. Additionally after hitting save on my VBA screen I am unable to interact with anything in the workbook at all. Below is my current attempts at VBA language for this. I know it probably looks like a bastardization of VBA but this was my most recent attempt with some chunks cut out.
Thank you to any of you who have taken the time to read this and attempt to help me (I promise I will try to understand the things you say!) and please let me know if there's any other information or details I can provide to help figuring out a solution to this. Any and all help is immensely appreciated! :)
.
Private Sub Worksheet_Calculate()
Dim Years, Property As Range
Set Years = Range("B3")
Set Property = Range("B4")
Select Case Years
Case Is = "Yes": Rows("16:53").EntireRow.Hidden = False 'All years are shown
Case Is = "No":Rows("16:20").EntireRow.Hidden = True
End Select
Select Case Property
Case Is = "Residental Rental - 27.5"Rows("16:22").EntireRow.Hidden = True
Case Is = "Nonresidential Real - 31.5"Rows("16:20").EntireRow.Hidden=True
Case Is = "Nonresidential Real - 39"Rows("16:53").EntireRow.Hidden=True
End Select
End Sub
Subreddit
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/excel/comme...