+ Reply to Thread
Results 1 to 4 of 4

Open form if cell in a range is selected

Hybrid View

  1. #1
    Forum Contributor Marco-Kun's Avatar
    Join Date
    04-14-2009
    Location
    Holland
    MS-Off Ver
    Dutch:2007
    Posts
    298

    Open form if cell in a range is selected

    Hello everyone,

    I have a form, called "Kalender", which has a Calendar. This form has the following code:

    Private Sub Calendar1_Click()
    ActiveCell.Value = Me.Calendar1.Value
    End Sub
    In my workbook I have this code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If ActiveCell.Address = "$B$5" Then Kalender.Show
    End Sub
    When I click on B5, the form opens. And whenever I pick a date, the value copies to B5.

    I'm trying to achieve this in a range. I want this to happen starting at B5 till B150.

    This should be a simple task, but I cant get it to work.

    Thanks a lot in advance!

    Marco
    Last edited by Marco-Kun; 03-24-2012 at 04:07 PM.

  2. #2
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Open form if cell in a range is selected

    Try this code out and let me know if it gets you the desired result

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Cells.Count > 1 Then Exit Sub
        If Not Intersect(ActiveCell, Range("B5:B150")) Is Nothing Then Kalender.Show
    End Sub
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  3. #3
    Forum Contributor Marco-Kun's Avatar
    Join Date
    04-14-2009
    Location
    Holland
    MS-Off Ver
    Dutch:2007
    Posts
    298

    Re: Open form if cell in a range is selected

    That's exactly what I wanted. Thank you very much for your help.

    Marco

  4. #4
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Open form if cell in a range is selected

    No problem, glad i could assist.

+ 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