+ Reply to Thread
Results 1 to 3 of 3

How to pop up a Macro when the cell in one column is selected-urge

Hybrid View

  1. #1
    Turboj
    Guest

    How to pop up a Macro when the cell in one column is selected-urge

    I know how to call a Macro when one cell is selected as below. But this only
    works when cell B1 is selected.

    But anybody knows how to trigger the macro when any cell in one column is
    selected (E.g when cell from B1 to B1000 is selected...) Thanks a lot!

    +++++++++++++++++++++++++++++++++++++++++++++
    Private Sub Worksheet_Selectionchange(ByVal Target As Range)

    If Target.Address = "$B$1" Then
    Call OpenCalendar
    End If
    End Sub
    +++++++++++++++++++++++++++++++++++++++++++++



  2. #2
    Dave Peterson
    Guest

    Re: How to pop up a Macro when the cell in one column is selected-urge

    if target.cells.count > 1 then exit sub 'only one cell at a time
    if intersect(target, me.range("b1:B1000")) is nothing then
    exit sub
    end if

    is one way.

    Turboj wrote:
    >
    > I know how to call a Macro when one cell is selected as below. But this only
    > works when cell B1 is selected.
    >
    > But anybody knows how to trigger the macro when any cell in one column is
    > selected (E.g when cell from B1 to B1000 is selected...) Thanks a lot!
    >
    > +++++++++++++++++++++++++++++++++++++++++++++
    > Private Sub Worksheet_Selectionchange(ByVal Target As Range)
    >
    > If Target.Address = "$B$1" Then
    > Call OpenCalendar
    > End If
    > End Sub
    > +++++++++++++++++++++++++++++++++++++++++++++


    --

    Dave Peterson

  3. #3
    Turboj
    Guest

    Re: How to pop up a Macro when the cell in one column is selected-

    Thanks Dave. The problem is well solved. The final codes are as below.

    +++++++++++++++++++++++++++++++++++++++++++
    Private Sub Worksheet_Selectionchange(ByVal Target As Range)

    If Target.Cells.Count > 1 Then Exit Sub 'only one cell at a time

    If Intersect(Target, Me.Range("G2:I5000,K2:K5000")) Is Nothing Then
    'column G to I & K needs data input

    Exit Sub
    End If

    Call OpenCalendar ' Call the macro to input date by using Calendar

    End Sub
    +++++++++++++++++++++++++++++++++++++++++++



    "Dave Peterson" wrote:

    > if target.cells.count > 1 then exit sub 'only one cell at a time
    > if intersect(target, me.range("b1:B1000")) is nothing then
    > exit sub
    > end if
    >
    > is one way.
    >
    > Turboj wrote:
    > >
    > > I know how to call a Macro when one cell is selected as below. But this only
    > > works when cell B1 is selected.
    > >
    > > But anybody knows how to trigger the macro when any cell in one column is
    > > selected (E.g when cell from B1 to B1000 is selected...) Thanks a lot!
    > >
    > > +++++++++++++++++++++++++++++++++++++++++++++
    > > Private Sub Worksheet_Selectionchange(ByVal Target As Range)
    > >
    > > If Target.Address = "$B$1" Then
    > > Call OpenCalendar
    > > End If
    > > End Sub
    > > +++++++++++++++++++++++++++++++++++++++++++++

    >
    > --
    >
    > Dave Peterson
    >


+ 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