VBA Cell interior color, fade from black to white [closed]

梦想与她 提交于 2019-12-13 06:09:09

问题


Im using Excel 2003 and would like to know the best way to change a cell's interior colour from black, and then gradually fade to white.

The idea being I will use the worksheet change event to slowly reveal some black text that is put into the cell in question.


回答1:


Try this:

Sub tester()
    FadeToWhite Selection.Offset(1, 0)
End Sub

Sub FadeToWhite(c As Range)
    Const SLOWNESS As Long = 300000
    Dim i As Long, v
    For i = 1 To 255 * SLOWNESS
        If i Mod SLOWNESS = 0 Then
            v = i / SLOWNESS
            c.Interior.Color = RGB(v, v, v)
            DoEvents
        End If
    Next i
End Sub


来源:https://stackoverflow.com/questions/24123413/vba-cell-interior-color-fade-from-black-to-white

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!