根据David的评论,你可以试试这个设置。
Dim r As Range
Private Sub CommandButton21_Click()
r.Offset(0, -1).Value = Time
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo halt
Application.EnableEvents = False
If Target.CountLarge > 1 Then GoTo moveon
Dim btn As OLEObject: Set btn = Me.OLEObjects("CommandButton21")
If Not Intersect(Target, Me.Range("B:B")) Is Nothing Then
Set r = Target
With btn
.Visible = True
.Left = r.Left
.Top = r.Top
.Width = r.Width
.Height = r.Height
End With
Else
btn.Visible = False
End If
moveon:
Application.EnableEvents = True
Exit Sub
halt:
MsgBox Err.Description
Resume moveon
End Sub
你需要与CommandButton21
作为它的名称创建一个ActiveX控件。
当B列中选择了某物时,此按钮将移动并显示。
您可以在CommandButton21_Click事件中添加排序例程。
来源
2015-04-01 03:34:12
L42
为什么不只有一个*按钮可以完成基于当前选中的任何单元的所有工作? – 2015-03-31 18:40:14
啊,这将工作,我该怎么做? – 2015-03-31 19:32:31
你会怎么做? – 2015-03-31 19:45:43