Private Sub Worksheet_Change(ByVal Target As Range)

pdetlefs

New Member
Joined
Oct 11, 2018
Messages
3
I am creating a macro enabled workbook with multiple named worksheets (eg, Input, H/W, Calcs, Quote, etc). I want to use the following to hide/unhide rows on 1 specific worksheet only. But so far its not working

Specifically I want to hide rows 7&8 on my "HW" worksheet when cell F5 (which is list validated cell, aka dropdown), changes from "Yes" to "No"

Private Sub Worksheet_Change (ByVal Target As Range)

If Range("E5").Value= "Yes" Then
Rows("7:8").EntireRow.Hidden= True
ElseI ifRange("E5").Value = "No" Then

Rows("7:8").EntireRow.Hidden= False
End If
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I've also tried....

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("E5").Address And Range("E").Value = "Ys" Then
Range("7:8").Rows.Hidden = False
Else
Range("7:8").Rows.Hidden = True
End If
End Sub
 
Upvote 0
Hi & welcome to MrExcel.

Couple of questions
Where is the code located?
Do you want to look at F5 as stated, or E5 as per the code?
 
Upvote 0
Thanks-I Got it working......I(I apologize for the code typo's, I should have cut and pasted rather than retype). The issue was I had the code under this workbook rather than the individual worksheet....duh.....
 
Upvote 0
Glad you fixed it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top