|
如何在一个sheet1中双击B列单元格将内容复制到sheet2中B列自动添加记录
sheet1: A B C sheet2: A B C
1 ID NAME "" 1 ID NAME
2 1 ASD 2 1 ASD
3 2 ZXC 3 2 ASD
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.EnableEvents = False
Dim i As Integer
Dim myrange As Range
ActiveCell.Select
If Target.Value <> "" Then
Selection.Copy
Worksheets("sheet2").Select
'Worksheets("sheet2").Activate
myrange = Worksheets("sheet2").Range("A2:A").Select '这句总是不能通过,请帮我看看错在那里。
i = Application.WorksheetFunction.Max(myrange) + 1
Worksheets("订单明细").Cells(i, 2).Select
Worksheets("订单明细").Cells(i, 2).paste
Application.CutCopyMode = False
Application.EnableEvents = True
End If
End Sub |
|