+ Reply to Thread
Results 1 to 3 of 3

On Action?

  1. #1
    John
    Guest

    On Action?

    I want to run a macro after the cell B7 is edited... currently the cell is a
    DATA>validation>list Does it need to be a Listbox?

  2. #2
    CWillis
    Guest

    RE: On Action?

    I use a list box in a program. When something is selected from the box, a
    macro is run. Here is the code. I hope this helps:

    'This sub runs when cell G7 is changed.
    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Cells.Count > 1 Then Exit Sub
    If Intersect(Range("G7"), Target) Is Nothing Then Exit Sub
    Const WS_RANGE As String = "G7"

    Application.EnableEvents = False
    If Range("G7").Value = "listboxoption1" Then
    Range("M7").Value = " "
    Range("M8").Value = " "
    ElseIf Range("G7").Value = "listboxoption2" Then
    Range("M7").Value = "typetexthere"
    Range("M8").Value = " "
    ElseIf Range("G7").Value = "listboxoption3" Then
    Range("M7").Value = "typetexthere"
    Range("M8").Value = " "
    ElseIf Range("G7").Value = "listboxoption4" Then
    Range("M7").Value = "typetexthere"
    Range("M8").Value = "typetexthere"
    End If
    Application.EnableEvents = True

    End Sub

    "John" wrote:

    > I want to run a macro after the cell B7 is edited... currently the cell is a
    > DATA>validation>list Does it need to be a Listbox?


  3. #3
    John
    Guest

    RE: On Action?

    Thanks, and I did something similar

    "CWillis" wrote:

    > I use a list box in a program. When something is selected from the box, a
    > macro is run. Here is the code. I hope this helps:
    >
    > 'This sub runs when cell G7 is changed.
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > If Target.Cells.Count > 1 Then Exit Sub
    > If Intersect(Range("G7"), Target) Is Nothing Then Exit Sub
    > Const WS_RANGE As String = "G7"
    >
    > Application.EnableEvents = False
    > If Range("G7").Value = "listboxoption1" Then
    > Range("M7").Value = " "
    > Range("M8").Value = " "
    > ElseIf Range("G7").Value = "listboxoption2" Then
    > Range("M7").Value = "typetexthere"
    > Range("M8").Value = " "
    > ElseIf Range("G7").Value = "listboxoption3" Then
    > Range("M7").Value = "typetexthere"
    > Range("M8").Value = " "
    > ElseIf Range("G7").Value = "listboxoption4" Then
    > Range("M7").Value = "typetexthere"
    > Range("M8").Value = "typetexthere"
    > End If
    > Application.EnableEvents = True
    >
    > End Sub
    >
    > "John" wrote:
    >
    > > I want to run a macro after the cell B7 is edited... currently the cell is a
    > > DATA>validation>list Does it need to be a Listbox?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1