gpt4 book ai didi

excel - 根据值突出显示第 3 列中的不同颜色的值

转载 作者:行者123 更新时间:2023-12-04 20:51:32 25 4
gpt4 key购买 nike

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。


2年前关闭。







Improve this question




我试图突出显示列 3 不同颜色中的值 谁能帮我弄清楚为什么我得到下一个没有错误。你们会怎么做呢?

谢谢!

Sub colorcode()
Dim lastrow As Long
lastrow = Range("D" & Rows.Count).End(xlUp).row
Dim ront
For ront = 13 To lastrow
If (Cells(ront, 4).Value <= 1199) Then
Cells(ront, 4).Interior.ColorIndex = 3
If (Cells(ront, 4).Value >= 1200 And Cells(ront, 4).Value <= 1299) Then
Cells(ront, 4).Interior.ColorIndex = 6
ElseIf (Cells(ront, 4).Value >= 1300 And Cells(ront, 4).Value <= 70) Then
Else
Cells(ront, 4).Interior.ColorIndex = 4
End If
Next ront
End Sub

最佳答案

我是初学者,但这段代码对我有用。您的最后一个条件不正确,您不能同时拥有大于 1300 和小于 70 的数字。所以我改成7000

还有For ront = 2 To lastrow将保持标题不变。

条件:

小于或等于 1199 - 颜色 RED

(大于等于 1200) (小于等于 1299) - 颜色 YELLOW

(大于等于 1300) (小于等于 7000)- 颜色为绿色

Sub colorcode()
Dim lastrow As Long
lastrow = Range("D" & Rows.Count).End(xlUp).Row
Dim ront
For ront = 2 To lastrow
If (Cells(ront, 4).Value <= 1199) Then
Cells(ront, 4).Interior.ColorIndex = 3
End If

If (Cells(ront, 4).Value >= 1200 And Cells(ront, 4).Value <= 1299) Then
Cells(ront, 4).Interior.ColorIndex = 6
End If

If (Cells(ront, 4).Value >= 1300 And Cells(ront, 4).Value <= 7000) Then
Cells(ront, 4).Interior.ColorIndex = 4
End If
Next ront
End Sub

关于excel - 根据值突出显示第 3 列中的不同颜色的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59001127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com