如果行(从b6开始)上的任何数据具有FAIL值,我希望从A6向下的A列将字体更改为粗体。然后,我想有一个显示具有黑体字的单元格计数的单元格。 到目前为止,下面是我所拥有的。
Sub Check_Results()
'
' Check_Results Macro
'
' Keyboard Shortcut: Ctrl+Shift+C
'
Sheets("Macro (2)").Select
Sheets("Macro (2)").Copy Before:=Sheets(1)
Sheets("Macro (2)").Select
Cells.Select
Selection.Copy
Sheets("Macro (3)").Select
Cells.Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("Macro (2)").Select
Cells.Select
Selection.Copy
Sheets("Macro (3)").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B20").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=+IF(('Macro (2)'!R5C)>0,IF(ABS('Macro (2)'!RC)>400%,IF(AND(ABS(PRE!RC)<100E-9,ABS(POST!RC)<100E-9),""pass"",""FAIL""),""pass""),IF(ABS('Macro (2)'!RC)>20%,""FAIL"",""pass""))"
Range("B20").Select
Selection.Copy
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.Paste
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Macro (2)").Select
Range("A1").Select
Sheets("Macro (3)").Select
Range("A1").Select
Cells.Select
Range("H15").Activate
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""pass"""
Selection.FormatConditions(1).Interior.ColorIndex = 35
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""FAIL"""
Selection.FormatConditions(2).Interior.ColorIndex = 3
Range("A1").Select
End Sub
答案 0 :(得分:0)
我能够使其正常工作,我在下面的底部添加了代码。
Range("A1").Select
Columns("B:B").Insert Shift:=xlToRight
Range("A19").Select
Selection.FormatConditions.Delete
ActiveCell.FormulaR1C1 = "Fail"
Range("B20").Select
ActiveCell.FormulaR1C1 = _
"=IF(COUNTIF(RC[+1]:RC[+51],R19C1),""F"","""")"
Range("B20").Select
Selection.AutoFill Destination:=Range("B20:B6000")
Range("B20:B6000").Select
ActiveCell.FormulaR1C1 = _
"=IF(COUNTIF(RC[+1]:RC[+51],R19C1),""F"","""")"
Range("B19").Select
ActiveCell.FormulaR1C1 = "=countif(R20C2:R6000C2,""F"")"
Range("B1").EntireColumn.AutoFit