VBA How To Hide and Unhide rows

kkoruni

New Member
Joined
Jul 18, 2017
Messages
23
Hi all,
I am in need of your help with vba code below.
My problem is that I am running into (Run-Time error '91': Object Variable or With block variable not set). Currently, I have Cells E73, and E128 to control whether rows hide or not hide. The problem I discovered is from all other cells that contain the same drop-down selection words and the VBA thinks it is an action it needs to take.
I have a drop-down selection of "Included" and "Excluded" on Cells (E26, E40, E51, E62, E73, E84, E95, E106, E117, E128, E139, E150). However, I want the following Cells to trigger whether rows hide or not.
Can you please help me to mark only Cells E73 and E128 to drive if rows hide or not hide, while ignoring the other cell's selection even if it has same wording?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.CountLarge > 1 Then Exit Sub
Select Case Target.Address(0, 0)
Case "E73"
Set rng = Sheets("Proposal").Rows("349:403")
Case "E128"
Set rng = Sheets("Proposal").Rows("404:462")
End Select
Select Case Target.Value
Case "Included"
rng.Hidden = False
Case "Excluded"
rng.Hidden = True
End Select
End Sub
 
It is making more sense now.
For what I am trying to achieve is very basic. Users will not be able to have free entry option but rather choose from a drop down selection which will avoid and errors.
This vba code wraps up the tool's functionality and I do not believe I will handle any more changes. one and done.
Truly this is very helpful and i appreciate all your help.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,215,030
Messages
6,122,762
Members
449,095
Latest member
m_smith_solihull

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