ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¸T¤î ÂùÀ»Àx¦s®æÃä¬É

[µo°Ý] ¸T¤î ÂùÀ»Àx¦s®æÃä¬É

¸T¤î ÂùÀ»Àx¦s®æÃä¬É
border double click.zip (17.39 KB)

§Ú¦³¤@­Ó EXCLE µe­±¤Ó¹L±K¶°¡A¸g±`¤£¤p¤ß ÂùÀ»¨ìÀx¦s®æªºÃä¬É´N²¾¨ìµe­±³Ì¤U­±¡A¤Q¤À§xÂZ

§Ú¤Wºô´M§ä¡A³Ì«á§ä¨ìªº¤è¦¡´N¬O±N TOOL->OPTION->EDIT->Allow cell drag and drop(¨Ï¥ÎÀx¦s®æ©ì©ñ¥\¯à¡^ ¨ú®ø


¤§«á§Ú§ä¨ì§ó¶i¤@¨Bªº³]©w¤è¦¡¡AÅý¯S©w°Ï°ìªº Ãä¬ÉÂùÀ»²¾°Ê¥¢®Ä

Dim SaveDragAndDrop As Variant 'For persistence, is declared at module level

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     'NOTE: This event fires first, then the Worksheet_BeforeDoubleClick event.
     '
     'WARNING: Setting a breakpoint in this event will, in effect, cancel any BeforeDoubleClick event, so you can't
     '         single-step through the whole sequence!
     
     'To prevent unwanted jumping to the "End" of a data-set if the user accidentally double-clicks onto the cell
     'border (which is an effect of CellDragAndDrop), disable that functionality while in the range where that
     'behavior is a problem.
     
    If Not Intersect(Target, Range("MyProtectedRange")) Is Nothing Then
         
        If IsEmpty(SaveDragAndDrop) Then
            SaveDragAndDrop = Application.CellDragAndDrop
            Application.CellDragAndDrop = False
        End If
    Else
         
        If Not IsEmpty(SaveDragAndDrop) Then
            Application.CellDragAndDrop = SaveDragAndDrop
            SaveDragAndDrop = Empty
        End If
    End If
End Sub





¦WºÙ MyProtectedRange =Sheet1!$C$4:$F$16

Book_ok.xls ÂI¿ï¶À¦â³¡¥÷¡A ÂùÀ»¨ìÀx¦s®æªºÃä¬É ¥¢®Ä

ÂI¿ïªÅ¥ÕÀx¦s®æ¡AÂùÀ»Ãä¬É²¾°Êªº¥\¯à ¦³®Ä

¦ý¬O³o­Óµ{¦¡¦³BUG ¡A·í§ÚÂI¶À¦â«á(¥¢®Ä)¡A¦A²¾¨ì SHEET2 ´N³q³q¥¢®Ä¤F¡A¥²»Ý²¾¦^SHEET1¡A¦AÂI¿ï¥Õ¦âÀx¦s¥i¤~·|¦A¥Í®Ä¡C

©Ò¥H§Ú±N SelectionChange ²¾¨ì ThisWorkBook Åܦ¨ SheetSelectionChange

¦ý¬O Intersect «o¦³°ÝÃD¡A½Ð°Ý¨º¦³°ÝÃD¡HÀ³¸Ó«ç»ò­×§ï¤~¯à¥¿½T
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

¦Û°Ý¦Ûµª¡G
¦b ThisWorkBook  ¥[¤J
Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Application.CellDragAndDrop = True
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Dim ProtectedRange As Range
Set ProtectedRange = Worksheets("Sheet1").Range("c4:f16")


If Sh.Name = "Sheet1" Then

        If Application.Intersect(Target, ProtectedRange) Is Nothing Then
                Application.CellDragAndDrop = True
        Else
                Application.CellDragAndDrop = False
        End If
Else
        
        Application.CellDragAndDrop = True
End If


End Sub


°ß¤@Åý§Ú¤£¸Ñªº¬O
Application.Intersect(Target, ProtectedRange)  ok

¬°¤°»ò
Application.Intersect(Target, MyProtectedRange)
MyProtectedRange =¦WºÙ = =Sheet1!$C$4F$16 ¬°¤°»ò´N¤£¦æ¡H
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

TOP

¦^´_ 2# eigen

¦³¿³½ìªº¡A¥i¥H¨ì https://www.mobile01.com/topicdetail.php?f=511&t=5120593&p=1#64021269

¬Ý¨ì¬ÛÃöªº°Q½×¡A§Ú¤]¦³¾ã²z§¹ªº½d¨Ò~~
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

TOP

¦^´_ 3# eigen


    ¦³¨S¦³°ª¤â¯à«üÂI¤@¤U¡A§Ú¥Î Application.CellDragAndDrop = False ' "½d³ò¤º"

¤w¸g¯à enable /disable ÂùÀ»Ãä¬Éªº¥\¯à

¦ý¬OApplication.CellDragAndDrop ³o­Ó¥\¯à¡A·|Åý Àx¦s®æµLªk³Q select / copy /paste ¡A¹ê¦b¬O¤Ó³Â·Ð¤F¡A¯à¤£¯à½Ð°ª¤â«üÂI¤@¤U¡H

¦p¦ó±N¥Ø«eselect/copy ªº¸ê®Æ³Æ¥÷¤U¨Ó¡H ¥H«K·í Application.CellDragAndDrop  ¤Á´«®É¡A¦AÁÙ­ì¦ì¸m¦^¨Ó
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

TOP

        ÀR«ä¦Û¦b : ªY½à§O¤H´N¬O²øÄY¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD