+ Reply to Thread
Results 1 to 5 of 5

copy&paste not avail if an event is running

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2003
    Posts
    39

    copy&paste not avail if an event is running

    Hello,
    I have a calendar that pops-up only when a specific range is selected,

    If I select a date, it works fine, but if select another cell that is out of the specific range (and without having selected a date in the calendar), I want it to close (visible = false). I then added the following line:
    If Application.Intersect(Target, Range("date")) Is Nothing Then
    Exit Sub
    Else
    Calendar1.Visible = False
    End If
    It works, but then it is no more possible to do copy&paste because when I select a different cell to paste, the macro runs and the copied cell is then lost (no more dashed blinking highlight)

    Any idea that could help?
    D
    Last edited by royUK; 04-16-2008 at 09:13 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You must use Code tags whewn posting code in your question.

    You don't say how you are triggering the macro, which event you are using. below is some code that will display a Calendar inserted into the worksheet, Visible property manually set to False.
    Private Sub Calendar1_Click()
        With Range("Paydate")
        .Value = CDbl(Calendar1.Value)
        .NumberFormat = "dd/mm/yyyy"
        .Select
        End With
        Calendar1.Visible = False
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Cells.Count > 1 Then Exit Sub
        If Target.Address <> "$D$3" Then 'where to display calendar
        Calendar1.Visible = False
        Exit Sub
        End If
     Calendar1.Visible = Not Calendar1.Visible
            Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
            Calendar1.Top = Target.Top + Target.Height
            Calendar1.Visible = True
            ' select Today's date in the Calendar
            Calendar1.Value = Date
        
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-18-2003
    Posts
    39
    Sorry, I don't know what code tags are...

    Thank's for your answer, but even with your code (which is similar to mine) it is not possible to cut & paste cells in the worksheet. That is my main problem and yet not solve...

    Any other suggestion?
    Thx,
    D

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you don't know what Code tags are then you haven't read the Forum Rules, please do so before posting again. You can see how the tags work if you click Edit on your first post.

    I don't understand what you expect to do, the code displays the Calendar if a cell in a certain range is selected, if a cell out of the range is selected the Calendar is invisible. What do you want to copy & paste?

  5. #5
    Registered User
    Join Date
    09-18-2003
    Posts
    39
    I want to copy & paste any cell content into any other cell (that is not in the target range).
    But with your code (and mine!) the macro always run, either to show the calendar, either to hide it.
    The consequence is that when I Ctrl+c a cell, as soon as I select another cell, it is no more possible to Ctrl+p because the macro had run (to hide the calendar) and then the cell to copy is no more in copy mode (blinking dashed highlight).
    Hope I am more clear this time. I enclosed a XLS file with your code in it (cells in yellow to be selected to activate the calendar). You can try to copy&paste any other cell for better understanding.
    Thx a lot helping me to sort this out,
    D
    Attached Files Attached Files

+ 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