我已经让它运行了,但它不能正常工作。(有趣的是,运行时,我指定的 SheetB 中只有一个单元格被更改为红色字体。)我的假设是,我没有在脚本中的正确位置指定要使用哪些工作表和/或范围,或者我的语法显然是错误的。谢谢你的帮助。
Sub RedBold()
'Sets color of current cell to red
With ActiveCell.Font
.Color = -16776961
.TintAndShade = 0
End With
ActiveCell.Font.Bold = True
End Sub
Option Explicit
Sub LowInventory()
Dim cell As Range
Dim deltaQ As Range
'Assign specific cell range in the Inventory Quantities sheet to variable deltaQ
Set deltaQ = Sheets("Inventory Quantities").[E3:E190]
'Conditional loop that checks for low deltaQ values and assigns a color to two specific cell ranges in the Inventory Costs, Sources sheet
For Each cell In deltaQ.Cells
'if deltaQ value is less than 2
If cell.Value < 2 Then
'Specify cell ranges in specific sheet to be affected by low inventory check loop
Sheets("Inventory Costs, Sources").Range("B3:B190, C3:C190").Select
Call RedBold
End If
Next
End Sub