Is it possible with macros?

nivetha

New Member
Joined
Nov 17, 2005
Messages
1
Hi All,

This is my first question and i hope this question is not a repeat (i already did a search). My requirement is like this, when a user opens a new worksheet, macro should display the list of valid keywords in the first column and it should display the another list of valid keywords based on the value selected in the first column and so on.

macro has to keep running till the user selects the keyword 'END' in the first column.

i hope my question is clear. is it possible to this in Excel macros?

- Nivetha.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
This is a way. Column A contains the main list of 10 items. Depending on which item is selected the appropriate column in the range B:K is unhidden.

The code runs each time a different cell is selected, and checks if the selected cell is in the correct range and performs the action - or not. So there is no need to have "END". If this gives a problem you may need to run it from a button.

Copy/Paste the code into the module for the worksheet. (Rightclick the tab then 'View code')
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Dim MainList As Range
    Dim MainListRow As Long
    Dim ShowColumn As Integer
    '--------------------------------------------------------
    Set MainList = Range("A1:A10")
    '- check list item selected
    Set isect = Intersect(Target, MainList)
    If isect Is Nothing Then Exit Sub
    '- hide/show columns
    MainListRow = Target.Row        ' row of selected cell
    ShowColumn = MainListRow + 1    ' column to show
    For c = 2 To 11
        If c = ShowColumn Then
            Columns(c).Hidden = False
        Else
            Columns(c).Hidden = True
        End If
    Next
 
Upvote 0

Forum statistics

Threads
1,211,789
Messages
6,103,985
Members
447,888
Latest member
eaydogan

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