VBA - lock/unlock cells after entry

donduc_jr

New Member
Joined
Apr 22, 2015
Messages
3
Hey guys, I need your help

Problem:

User choose a Location, after his decision, it is written in a cell. There are several tables for each Location. First they are all hidden, but if you have choosen a Location, the specific Location table is displayed, all others arent. This should be down automatically, so if the cell knows the Location, it Shows the appropriate Location table.

I ve already written the code for the question with the Location, and it puts the data into a cell. But I need help, for the described Problem above.

The Location tabels are for example:

AL: A3-A20
WI: A22-A39
...and so on

2u7swid.png


the chosen Location from the user is for example in cell A1 (WI, but imagine it would be AL), so from there we would know, which Location he has Chosen, so AL Location Table (A3-A20) would be displayed.

All tables are by Default hidden.

Greets
Donduc_jr.
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo halt
    Application.EnableEvents = False
    With Me
        If Not Intersect(Target, .Range("A1")) Is Nothing Then
            .Range("A3:A39").EntireRow.Hidden = True ' change to your actual range
            Select Case .Range("A1") ' UCase(.Range("A1")) to make it case insensitive
            Case "AL": .Range("A3:A20").EntireRow.Hidden = False
            Case "WI": .Range("A22:A39").EntireRow.Hidden = False
            Case Else ' add other condition to suit
            End Select
        End If
    End With
moveon:
    Application.EnableEvents = True
    Exit Sub
halt:
    MsgBox Err.Description
    Resume moveon
End Sub

What about this??? I think it should work
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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