首先,我很抱歉这是一个重复的问题,我似乎找不到答案,但是我可能搜索错误。
我有一些想要改变颜色的形状。单击后,他们会弹出一个用户表单。提交用户表单时,我想将形状的颜色从红色更改为绿色(以指示完成)。
我最初将用户窗体中的信息和形状名称记录在一个单独的工作表(“记录表”)中,然后我想更改被单击的形状的颜色。
Sub SubmitButton_Click()
Dim RecordSheet As Worksheet
Dim BottomRow As Integer
Dim ButtonText As String
Set RecordSheet = Worksheets("Record Sheet")
BottomRow = WorksheetFunction.CountA(RecordSheet.Range("A:A")) + 1
ButtonText = Application.Caller
RecordSheet.Cells(BottomRow, 1) = Now()
RecordSheet.Cells(BottomRow, 2) = ButtonText
RecordSheet.Cells(BottomRow, 3) = IssuesTextBox.Value
If No.Value = True Then
RecordSheet.Cells(BottomRow, 4) = "No"
Else
RecordSheet.Cells(BottomRow, 4) = "Yes"
End If
'Changing the color of the shape that was clicked here
Unload Me
End Sub
答案 0 :(得分:0)
假设形状是链接到宏的常规excel形状...保存单击的原始图纸和形状,执行代码...然后更改形状的填充颜色...就像...
Sub ShapeSubmitButton_Click()
Dim vSheet As Worksheet
Dim vShape As Shape
Set vSheet = ActiveSheet
Set vShape = vSheet.Shapes(Application.Caller)
' YOUR CODE HERE ....
vShape.Fill.ForeColor.RGB = rgbGreen
End Sub