A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Thank you, again Hans.
Sorry for asking too many question but how do I resize the rows to fit the contents in column B.
Regards,
Shaynne
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, All.
I have to create an excel spreadsheet where the next 2 rows stay hidden if the answer is No or N/A or blank.
In the sample below:
* Column A with item number (1,2,3....) has a drop down list of ("Yes"or "No"or "N/A") in column C. I used Data Validation for this.
* Rows with no item number should stay hidden (rows 10,11,13,14,16&17) until "Yes" has been selected from the drop down list in column C.
* If the item in column C (C9) has no answer (or blank), rows 10 & 11 should stay hidden - I hide the rows manually for this purpose.
* Items with "No"or "N/A" has been selected from the drop down list in column C, the next 2 rows should stay hidden. Rows 16 & 17 should stay hidden in this sample.
* If "Yes" has been selected from the drop down list in column C, the content in column B for the next 2 rows (rows 13&14) will appear.
* Column B has IF formula that auto populates if the answer is "Yes".
I will really appreciate your assistance on this.
Thank you in advance!
Regards,
Shaynne
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
Thank you, again Hans.
Sorry for asking too many question but how do I resize the rows to fit the contents in column B.
Regards,
Shaynne
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
Hi, Hans.
Thank you so much for the prompt response.
When I tried to run the code for the first it worked but when I tried to protect the sheet, the next 2 rows didn't appear when I selected yes.
Kind Regards,
Shaynne
Right-click the sheet tab.
Select 'View Code' from the context menu.
Copy the following code into the worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Range("C:C"), Target) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each rng In Intersect(Range("C:C"), Target)
rng.Offset(1).Resize(2).EntireRow.Hidden = (rng.Value <> "Yes")
Next rng
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
Switch back to Excel.
Save the workbook as a macro-enabled workbook (.xlsm).
Make sure that you allow macros when you open the workbook.