Consulting

Results 1 to 9 of 9

Thread: Solved: button that follows by click unables copying

  1. #1
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location

    Solved: button that follows by click unables copying

    Hi,

    with the help of this forum i've a macro that makes the commandbutton follow by click, but now i cann't copy and paste because the button cancels the selection.

    Who has a solution that makes both possibly ( button that follows and copying)

    Ger
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    [VBA]Private Sub CommandButton1_Click()
    controle
    End Sub[/VBA]

    I am afraid that this procedure is nowhere to be found in the attachment.

  3. #3
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location
    Indeed i didn't submit procedure Controle. Because it is not necessary.
    If i select a range for example A4 to a26 and try to copy this to H4 to H 26 the selection is gone as soon as i click on H4.

    Ger

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Hi Ger, when looking at your workbook, I too can copy but not paste the cells because the Paste and PasteSpecial options are greyed out.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location
    Aussiebear,
    that is my problem. If I delete the code that makes the commandbutton follow the cursor than i can copy and paste, so the code must make it impossible to copy and paste.

    Ger

  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Why not make the button fixed in position, but make the sheet scroll?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #7
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location
    Because of the structure of the sheet i prefer a floating commandbutton.

    Ger

  8. #8
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You might try changing the worksheet code to:
    [vba]

    Private Declare Function CloseClipboard Lib "User32" () As Long
    Private Declare Function OpenClipboard Lib "User32" (ByVal hWnd As Long) As Long

    Private Sub CommandButton1_Click()
    controle
    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim blnClip As Boolean
    Dim Shp As Object
    If Application.CutCopyMode <> False Then
    blnClip = True
    OpenClipboard 0&
    End If
    Set Shp = ActiveSheet.CommandButton1

    With Shp
    .Left = ActiveCell.Left
    .Top = ActiveWindow.Top
    .Width = 90 ' or a desired fixed width
    .Height = 45 ' or a desired fixed height
    End With

    Shp.Object.TakeFocusOnClick = False 'Optional. keeps focus on the selected cell instead of the button
    If blnClip Then CloseClipboard
    End Sub
    [/vba]
    Be as you wish to seem

  9. #9
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location
    Thx Aflatoon,

    this works fine.

    Ger

Posting Permissions

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