无法在Excel VBA中更改字体颜色

时间:2022-11-21 08:50:04

I can trying to change font color in Excel Sheets.

我可以尝试在Excel表格中更改字体颜色。

Code is:

Sub sbChangeFontColor()

Cells(4, 2).Font.ColorIndex = 3 

Range("B4").Font.ColorIndex = 3

Cells(4, 2).Font.Color = RGB(255, 0, 0)

Range("B4").Font.Color = RGB(255, 0, 0)

End Sub

Already, I used these code in Macros of my Excel Sheet. When I run the Macros code, Excel Sheet Font not changed and also not throwing any error messages. How to solve this problem?

我已经在Excel表格的宏中使用了这些代码。当我运行宏代码时,Excel工作表字体没有更改,也没有抛出任何错误消息。如何解决这个问题呢?

1 个解决方案

#1


There is no error in your code..........the cells are being coloured on some worksheet.....the Active worksheet.

您的代码中没有错误..........单元格正在某些工作表上着色.....活动工作表。

Check your sheets and Select the proper sheet before running the code.

检查工作表并在运行代码之前选择正确的工作表。

#1


There is no error in your code..........the cells are being coloured on some worksheet.....the Active worksheet.

您的代码中没有错误..........单元格正在某些工作表上着色.....活动工作表。

Check your sheets and Select the proper sheet before running the code.

检查工作表并在运行代码之前选择正确的工作表。