[英]How to delete button from a specific cell?
I have a log with several entries.我有一个包含多个条目的日志。 I enter additional data into a row, for example into cell "G3".我将附加数据输入一行,例如单元格“G3”。
If the entered data is a valid date, a button is created in a neighboring cell "J3" of that row如果输入的数据是有效日期,则会在该行的相邻单元格“J3”中创建一个按钮
Public Sub Worksheet_Change(ByVal target As Range)
Dim intersection As Range
Dim RgBtn As Range
Dim Btn As Shape
Dim wS As Worksheet
Set intersection = Intersect(target, Columns(7))
Set wS = ThisWorkbook.Sheets("Log") 'Worksheet
If Not intersection Is Nothing Then
If IsDate(target.Value) Then
'MsgBox "Cell " & Target.Address(0, 0) & " contains a valid date."
'Add Button:
wS.Unprotect "DoNotChange!"
Set RgBtn = wS.Range("J" & target.row)
Set Btn = wS.Shapes.AddFormControl(xlButtonControl, RgBtn.Left, RgBtn.Top, RgBtn.Width, RgBtn.Height)
With Btn
.OnAction = "'CreateInvoice " & target.row & "'"
.OLEFormat.Object.Text = "Create Entry"
End With
Else
'MsgBox "Error..."
End If
End If
End Sub
When I click that button, data from that range(A3:F3) is copied to another sheet.当我单击该按钮时,该范围(A3:F3)中的数据被复制到另一张纸上。
I want, after clicking on that button, the button is deleted and replaced by the text "completed".我希望,在单击该按钮后,该按钮被删除并替换为“已完成”文本。
I tried several approaches to deleting that button.我尝试了几种删除该按钮的方法。
You can hide the button.您可以隐藏按钮。
With btn
.Visible = Not .Visible
End with
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.