Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

如何在Excel中閃爍或閃爍指定單元格的文本?

為了使某個單元格在工作表中突出顯示,如何使該單元格的文本閃爍? 本文將向您展示使Excel中指定單元格的文本閃爍的方法。

用VBA代碼閃爍或閃爍指定單元格的文本


用VBA代碼閃爍或閃爍指定單元格的文本

請執行以下操作以閃爍Excel中指定單元格的文本。

1。 按 其他 + F11 同時打開 Microsoft Visual Basic for Applications 窗口。

2。 在裡面 Microsoft Visual Basic for Applications 窗口中,單擊 插入 > 模塊。 然後將以下代碼複製並粘貼到“代碼”窗口中。

VBA代碼:在Excel中閃爍指定單元格的文本

Sub StartBlink()
'Updated by ExtendOffice 20181010
    Dim xCell As Range
    Dim xTime As Variant
      On Error Resume Next
    Set xCell = Range("Sheet2!A1")
  On Error Resume Next
   
        If xCell.Font.Color = vbRed Then
            xCell.Font.Color = vbWhite
        Else
            xCell.Font.Color = vbRed
        End If
    xTime = Now + TimeSerial(0, 0, 1)
    Application.OnTime xTime, "'" & ThisWorkbook.Name & "'!StartBlink", , True
End Sub

備註:在此VBA代碼中,Sheet2和A1表示Sheet1單元格A2中的文本在當前工作簿中將閃爍。

3。 按 其他 + Q 同時關閉按鍵 Microsoft Visual Basic for Applications 窗口。

現在,您需要一個按鈕來開始和停止閃爍。

4。 點擊 開發人員 > 插入 > 按鈕(表單控件)。 看截圖:

5.在工作表中繪製一個按鈕,然後 分配宏 彈出對話框,請點擊 開始閃爍 名稱 框,然後單擊 OK 按鈕。 看截圖:

6.右鍵單擊插入的按鈕,然後單擊 編輯文字 從右鍵單擊菜單中。 然後將按鈕文本更改為所需的文本,例如“開始/停止閃爍”。

從現在開始,單擊按鈕時,單元格A1的文本開始閃爍。 當再次單擊該按鈕時,單元格A1的文本停止閃爍。


最佳辦公效率工具

Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及您以前使用過的任何東西; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
  • 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不會丟失數據; 拆分單元格內容; 合併重複的行/列...防止細胞重複; 比較範圍...
  • 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
  • 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
  • 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
  • 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
  • 超過300種強大功能。 支持Office / Excel 2007-2019和365。支持所有語言。 在您的企業或組織中輕鬆部署。 完整功能30天免費試用。 60天退款保證。
kte選項卡201905

Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 每天將您的工作效率提高50%,並減少數百次鼠標單擊!
officetab底部
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    shalim · 5 months ago
    how to make flashing specific cell containing specific Text only ?

  • To post as a guest, your comment is unpublished.
    connie · 1 years ago
    not working,

    Please help
  • To post as a guest, your comment is unpublished.
    Shreenivas AK · 1 years ago
    when protect the sheet this code not working
  • To post as a guest, your comment is unpublished.
    mekka · 2 years ago
    hi, i need help in google sheets..

    I need an entire row to blink if F3:F1001 contains the "STAT". the entire row should be in orange but also blinking until the the column W3:W1001's checkbox is ticked.

    is it possible? can you help? pleaseeeeeeeeeeeeeee
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi mekka,
      Sorry can't help you with that. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    baburaj.sasco@gmail.com · 2 years ago
    How can I put a condition to blink certain cells if its value is below a limit, say below 30, without using the button. Also, i will be using a protected sheet. Thanks in advance for your help.
  • To post as a guest, your comment is unpublished.
    Sam · 2 years ago
    How do i change this to sheet 1?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Sam,
      If you want to make cell A1 in Sheet1 or other specific worksheet blinking, please add "Sheet1!" or other worksheet name before the cell address. See the below code line:

      Set xCell = Range("Sheet1!A1")
  • To post as a guest, your comment is unpublished.
    SUNARYANTO · 2 years ago
    MANTEB GAN
  • To post as a guest, your comment is unpublished.
    alassail.survey@gmail.com · 2 years ago
    Working. good
    But after protecting my sheet LOCK & Hidden ( except blinking cell ) it's not working.
    Anyone plz help me solve this issue.
  • To post as a guest, your comment is unpublished.
    Rashid Imam · 2 years ago
    Hi,
    it's working well but when I am protecting my sheet then blinking is not working showing debug msg.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Please try the following code.

      Sub StartBlink()
      Dim xCell As Range
      Dim xTime As Variant
      On Error Resume Next
      Set xCell = Range("A1")
      On Error Resume Next

      If xCell.Font.Color = vbRed Then
      xCell.Font.Color = vbWhite
      Else
      xCell.Font.Color = vbRed
      End If
      xTime = Now + TimeSerial(0, 0, 1)
      Application.OnTime xTime, "'" & ThisWorkbook.Name & "'!StartBlink", , True
      End Sub
  • To post as a guest, your comment is unpublished.
    Dayle · 3 years ago
    How do I include this code in the following so I don't need buttons but the blinking starts automatically on the workbook opening?

    Private Sub Workbook_Open()

    ' code here

    End Sub
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Hi Dayle,
      Please put this code into the ThisWorkbook window.

      'Put in“ThisWorkbook”window
      Private Sub Workbook_Open()
      StarBlink
      End Sub

      Put the below code into the Module window. And then save the workbook as an Excel Macro-enabled Workbook. Hope I can help. Thanks for your comment.

      'Start blinking
      Sub StarBlink()
      Dim xCell As Range
      Dim xTime As Variant
      Set xCell = Range("A1")
      With ThisWorkbook.Worksheets("Sheet1").Range("A1").Font
      If xCell.Font.Color = vbRed Then
      xCell.Font.Color = vbWhite
      Else
      xCell.Font.Color = vbRed
      End If
      End With
      xTime = Now + TimeSerial(0, 0, 1)
      Application.OnTime xTime, "" & ThisWorkbook.Name & "!StarBlink", , True
      End Sub
      'Stop blinking
      Sub StopBlink()
      xTime = Now + TimeSerial(0, 0, 1)
      Application.OnTime EarliestTime:=xTime, Procedure:="" & ThisWorkbook.Name & "!StarBlink", Schedule:=False
      End Sub
  • To post as a guest, your comment is unpublished.
    Rafi · 3 years ago
    Working... Great
  • To post as a guest, your comment is unpublished.
    Hana · 4 years ago
    How can it make a random cell blink in a certain range?
  • To post as a guest, your comment is unpublished.
    Geoff Culbertson · 4 years ago
    Could this blinking text be applied to a condition. i.e. if a date is reached or is approaching on one worksheet, a cell on a cover/menu sheet flashes
  • To post as a guest, your comment is unpublished.
    Ken · 4 years ago
    This code will not stop the blinking it get stuck. What am I doing wrong?