- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有 3 张工作表的 Excel 工作簿,前两张包含大量数据,第三张是空白的。
我想创建一个宏,从表 1 和 2 中复制所有突出显示/黄色的单元格并将它们粘贴到表 3 中。
我在宏中有一些代码,目前只是将工作表 1 复制到工作表 3,但即使我使用了 If .Interior.ColorIndex
,它也会复制所有内容
Sub Yellow()
Dim LR As Long, i As Long, j As Long
j = 1
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Worksheets("Sheet1").Range("A1:CF200" & i)
If .Interior.ColorIndex Like 27 Or 12 Or 36 Or 40 Or 44 Then
.Copy Destination:=Worksheets("Sheet3").Range("J" & j)
j = j + 1
End If
End With
Next i
End Sub
最佳答案
更新:下面的代码修改为跳过黄色突出显示的空白单元格...
我可能会将它分为两个部分,一个循环遍历工作表的脚本和一个检查单元格 (Range
) 是否为黄色的函数。下面的代码有很多注释,这些注释贯穿了这些步骤:
Option Explicit
Sub PutYellowsOnSheet3()
Dim Sh As Worksheet, Output As Worksheet
Dim LastRow As Long, LastCol As Long
Dim Target As Range, Cell As Range, Dest As Range
Dim DestCounter As Long
'initialize destination counter and set references
DestCounter = 1
Set Output = ThisWorkbook.Worksheets("Sheet3")
'loop through sheets that are not named "Sheet3"
For Each Sh In ThisWorkbook.Worksheets
If Sh.Name <> "Sheet3" Then
With Sh
LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LastCol = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
Set Target = .Range(.Cells(1, 1), .Cells(LastRow, LastCol))
End With
For Each Cell In Target '<~ loop through each cell in the target space
If AmIYellow(Cell) And Cell.Value <> "" Then '<~ blank check too
Set Dest = Output.Cells(DestCounter, 1)
Cell.Copy Dest
DestCounter = DestCounter + 1 '<~ keep incrementing on sheet 3
End If
Next Cell
End If
Next Sh
End Sub
'call this function when you'd like to check if a range is yellow
Public Function AmIYellow(Cell As Range) As Boolean
If Cell Is Nothing Then
AmIYellow = False
End If
Select Case Cell.Interior.ColorIndex '<~ this is the yellow check
Case 27, 12, 36, 40, 44
AmIYellow = True
Case Else
AmIYellow = False
End Select
End Function
关于vba - Excel 将工作表 1 和 2 中突出显示/黄色的所有值复制到工作表 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23952213/
北京时间今天下午,realme 5i手机正式登陆印度市场,5000mAh+骁龙665处理器,售价约合人民币870元。在发布会上,realme的印度CEO马达夫·希思(Madhav Sh
这个问题在这里已经有了答案: What does a space mean in a CSS selector? i.e. What is the difference between .clas
我配置了 Jenkins 构建(项目使用 Java、Maven、JUnit)。根据单元测试失败的 Maven 阶段,我想将构建标记为红色、黄色或绿色: 编译错误:红色 Maven 阶段“测试”失败:红
我想知道是否可以在“solidGauge”图表的右侧设置一个从左侧绿色(0 值)开始、中间渐变为黄色然后渐变为红色的渐变。 我在 yAxis 中尝试了一些配置,但它们没有按照我的要求进行:
我正在使用 cocos2d 库制作 iOS 游戏。 假设您有两个具有两种不同颜色的对象 - 在 RGB 中定义为 Blue: 0,0,255 Yellow: 255,255,0 我想添加蓝色和
有没有办法轻松地将给定的十六进制颜色代码分配给更一般的类别(红色、绿色、蓝色、黄色、橙色、粉色、黑色、白色、灰色……)? 比如 #ffcc55 -> 橙色,#f0f0f0 -> 白色,... 编辑:甚
我必须区分5种类型的图像,这些图像可能主要是红色,绿色,蓝色,橙色或黄色,而白色或黑色。我必须找到图像中突出的颜色。 图像来源是网络摄像头,因此实际颜色还取决于图像的照明度和距网络摄像头的距离。我的图
我一直在寻找如何在 qtableview 的特定单元格上设置颜色。目前,我正在使用 qt 示例卡住列来查看如何在特定单元格上设置颜色。 我在论坛上搜索有关如何告诉使用 qitemdelegate 或
我是一名优秀的程序员,十分优秀!