VBA - Hide range of rows IF

adamsmith388

New Member
Joined
Mar 12, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Never dabbled with VBA before and tried a few things on this forum but can't work out how to manipulate the code to work for me.
Any additional info to speed it up, or prevent crashing when i add more would also be useful.

Private Sub Worksheet_Change(ByVal Target As Range)
If Range (B18!) = "None" Then
Rows("72:82").Entire.Row.Hidden = True
Else
Rows("72:82").Entire.Row.Hidden = False
End IF
End Sub

The concept is if there are Hypothetical calculations needed the rows are visible, if they are not the rows are hidden.
B18 will wither be a simple Yes/No text input or at most a dropdown selection.
 

Attachments

  • VB Query.png
    VB Query.png
    57 KB · Views: 7

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Unfortunately due to the data we handle, our environment runs in CITRIX so are unable to create mini sheets or add plug-ins that would allow me to do so.
 
Upvote 0
hope below code will help you get what you want

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B18")) Is Nothing Then
If Range("B18").Value = "None" Then
Rows("72:82").EntireRow.Hidden = True
Else
Rows("72:82").EntireRow.Hidden = False
End If
End If
End Sub
 
Upvote 0
Maybe this code could do the job.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Address = "$B$18" Then Rows("72:82").Hidden = Target.Value = "None"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,088
Messages
6,123,056
Members
449,091
Latest member
ikke

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