excel vba ¦pªG§â¤GÄ檺¸ê®Æcopy¨ì¥t¤GÄæ©O?
- ©«¤l
- 16
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 55
- ÂI¦W
- 0
- §@·~¨t²Î
- macOS / Windows
- ³nÅ骩¥»
- Office 2010/2019
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2020-7-9
- ³Ì«áµn¿ý
- 2021-8-7
|
¥»©«³Ì«á¥Ñ cody ©ó 2020-7-23 00:58 ½s¿è
°Ñ¦Ò¬Ý¬Ý
module:- Sub copyBCtoEF()
- With Worksheets("test1")
- .Range("E:F").Value = .Range("B:C").Value
- End With
- End Sub
½Æ»s¥N½X- Sub doUNDO()
- With Application
- .EnableEvents = False
- .Undo
- .EnableEvents = True
- End With
- End Sub
½Æ»s¥N½X worksheet:- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.EnableEvents = False
-
- If Target.Row = 1 Then
- doUNDO
- MsgBox "¤£¥i§ó§ï¼ÐÃD"
- GoTo tagExit
- End If
-
- If (Target.Column = 2 Or Target.Column = 3) And (Target.Row >= 2 Or Target.Row >= 2) And Target.Count = 1 Then
- With Worksheets("test1")
- .Cells(Target.Row, Target.Column + 3).Value = .Cells(Target.Row, Target.Column).Value
- End With
- GoTo tagExit
- End If
-
-
-
- If (Target.Column = 2 Or Target.Column = 3) And (Target.Row >= 2 Or Target.Row >= 2) And Target.Count >= 2 Then
-
- With Worksheets("test1")
- .Range(.Cells(Target.Row, Target.Column + 3), .Cells(Target.Row + UBound(Target.Value2, 1) - 1, Target.Column + UBound(Target.Value2, 2) - 1 + 3)).Value = Target.Value2
- End With
- GoTo tagExit
- End If
-
- tagExit:
- Application.EnableEvents = True
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|