Multiple Rows to hide in VB

GlennY

Board Regular
Joined
Jan 22, 2009
Messages
103
I have a dropdown with 2 selections (PHYSICAL & VIRTUAL).
If Physical is selected i need to hide rows 31 thru 70 and display rows 13 thru 30
If Virtual is selected i need to hide rows 13 thru 30 and display rows 31 thru 70.

I am trying to do this in the Microsoft VB code (below) but i cannot get it to work properly.


If Not Intersect(Target, Range("B11")) Is Nothing Then
If Range("B11") = "Virtual" Then
Rows("31:70").Hidden = False
Else
Rows("13:30").Hidden = True
End If
End If
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
If Not Intersect(Target, Range("B11")) Is Nothing Then
    If Range("B11") = "Virtual" Then
        Rows("31:70").Hidden = False
        Rows("13:30").Hidden = True
    Else
        Rows("13:30").Hidden = False
        Rows("31:70").Hidden = True
    End If
End If
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,881
Hi

Try:

Code:
If Not Intersect(Target, Range("B11")) Is Nothing Then
    Rows("13:30").Hidden = (Range("B11") = "Virtual")
    Rows("31:70").Hidden = (Range("B11") = "Physical")
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,122,489
Messages
5,596,455
Members
414,069
Latest member
StudExcel

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
Top