+ Reply to Thread
Results 1 to 2 of 2

SelectionChange disables Copy/Cut & Paste

Hybrid View

  1. #1
    Registered User
    Join Date
    02-20-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    5

    SelectionChange disables Copy/Cut & Paste

    Hi there,

    I have the following code written in my worksheet SelectionChange procedure

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        
        Set CurrentRange = Target
        
        
        If Target.Column >= 2 And Target.Column <= 14 Then
            
            SortMe.Left = Target.Left
            SortMe.Top = 0
            SortMe.Width = Range(Split(Target.Address(False, False), ":")(0) & "1").Width + 1.5
            
            If Target.EntireColumn.Address = Target.Address Then
                SortMe.Height = Range(Split(Target.Address(False, False), ":")(0) & "1").Height + 1.5
                SortMe.Caption = "Sort"
            Else
                SortMe.Height = Range(Split(Target.Address(False, False), ":")(0)).Offset(1 - Target.Row).Height + 1.5
                SortMe.Caption = Range(Split(Target.Address(False, False), ":")(0)).Offset(1 - Target.Row).Value
            End If
            
            SortMe.Enabled = True
            SortMe.Visible = True
            
        Else
            
            SortMe.Visible = False
            SortMe.Enabled = False
            SortMe.Caption = "Sort"
            
        End If
            
    End Sub
    "SortMe" is an ActiveX Command Button.

    All my code runs fine except for one problem: I cannot do a copy/cut & paste on the worksheet with this code. It seems like every time a selection change was triggered, the CutCopyMode (aka clipboard) gets cleared.


    Does anyone have any idea what I'm doing wrong here?

  2. #2
    Registered User
    Join Date
    02-20-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    5

    Re: SelectionChange disables Copy/Cut & Paste

    I've figured out that as soon as I've made adjustments to SortMe (ActiveX Command Button), the application.cutcopymode = 0 (false).

    Is there anyway to avoid cutcopymode being changed by this?

+ 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