我有以下数据:
target_gene A B C D
LETMD1 2.479 1.784 2.446 2.172
HHEX 0.343 0.010 0.313 0.166
CLNK 0.000 0.090 0.000 0.000
TAL1 0.000 0.000 0.041 0.000
使用Microsoft Excel,我手动条件格式 - >色标
内容逐行,结果如下
实际上,我有几千行需要处理。怎么样 我可以在Excel中方便地(或以编程方式)执行此操作吗?
我正在使用MS Excel v15.31 for Macintosh。
答案 0 :(得分:2)
在宏录制器的帮助下,您可以将其置于For...Next
循环
Sub formatRows()
Dim r As Long
With ThisWorkbook.Worksheets(1)
For r = 1 To .Cells(.Rows.Count, 1).End(xlUp).Row
With .Rows(r)
.FormatConditions.AddColorScale ColorScaleType:=3
.FormatConditions(.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).ColorScaleCriteria(1).Type = _
xlConditionValueLowestValue
With .FormatConditions(1).ColorScaleCriteria(1).FormatColor
.Color = 13011546
.TintAndShade = 0
End With
.FormatConditions(1).ColorScaleCriteria(2).Type = _
xlConditionValuePercentile
.FormatConditions(1).ColorScaleCriteria(2).Value = 50
With .FormatConditions(1).ColorScaleCriteria(2).FormatColor
.Color = 16776444
.TintAndShade = 0
End With
.FormatConditions(1).ColorScaleCriteria(3).Type = _
xlConditionValueHighestValue
With .FormatConditions(1).ColorScaleCriteria(3).FormatColor
.Color = 7039480
.TintAndShade = 0
End With
End With
Next r
End With
End Sub