Skip to content

Instantly share code, notes, and snippets.

@DuongAQ
Created February 21, 2018 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DuongAQ/f5a91a2c2c6a03423a5c6039b9095bb1 to your computer and use it in GitHub Desktop.
Save DuongAQ/f5a91a2c2c6a03423a5c6039b9095bb1 to your computer and use it in GitHub Desktop.
Sub Shape_ChangeColour() 'Lệnh đổi màu Shape
Dim shp As Object
'Xác định Shape cần đổi màu
Set shp = Sheet1.Shapes("Rectangle 1")
'Nằm tại Sheet1
'Tên là Rectangle 1
'Logic thực hiện việc đổi màu
If [F9] = 1 Then 'Xét kết quả tại ô F9 nếu có giá trị là 1
[F9] = 2 'Lấy kết quả ô F9 bằng 2 để ghi nhận đã đổi màu
shp.Fill.Visible = msoTrue
shp.Fill.ForeColor.RGB = RGB(255, 0, 0)
Else 'Trường hợp không phải giá trị là 1
[F9] = 1 'Trả về giá trị là 1, có thể bỏ qua nếu không cần thiết
shp.Fill.Visible = msoFalse 'Trả về trạng thái ban đầu của shape
End If 'Kết thúc câu lệnh IF
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment