excel - 如果为真,则搜索 B 列中的文本并将其他文本传递到 L 列
问题描述
我需要在 B:B 列中搜索特定文本,然后如果真的将其他文本粘贴到 L:L 列,例如:
Sub teste()
Application.ScreenUpdating = False
last = Cells(Rows.Count, "B").End(xlUp).Row
For i = last To 1 Step -1
If (Cells(i, "B").Value) = "string_1" Then
Range("L2").Select
ActiveCell.FormulaR1C1 = "some_text_1"
'LastRow = Range("A" & Rows.Count).End(xlUp).Row
'Range("L2").AutoFill Destination:=Range("L2:L" & LastRow)
End If
Next i
End Sub
如果为真,我只能粘贴第一个文本,或者用相同的文本填充 L:L 列。
解决方案
你的意思是这样的吗?
- 如果 B 列是,
string_1
则将 C 列复制到 L 列
For i = last To 1 Step -1
If (Cells(i, "B").Value) = "string_1" Then
'copy value from C to L
Cells(i, "L").Value = Cells(i, "C").Value
End If
Next i
您可能会从阅读 如何避免在 Excel VBA 中使用 Select 中受益。
推荐阅读
- python-3.x - 熊猫,为什么对其他行进行除法会导致最后一行出现额外的尾随零?
- python - python使用re.search匹配来自javascript的值
- mysql - 如何更改 laravel db 查询生成器括号
- android - 如何修复 Gradle 任务 assembleDebug 失败并退出代码 -1?
- typescript - 导入的打字稿枚举在编译输出中不起作用
- angular - 部署 angular 8 和 asp.net core 3.1 的步骤
- php - Facebook 登录:跨站请求伪造验证失败。URL 和会话中的“状态”参数不匹配
- c# - 将 Node JS 转换为 ASP.NET C# 以获取 HMAC_SHA256 哈希
- java - 我在 javaFX 中工作,想通过在 obserableArrayList 中添加数据来填充 tabelView,方法是访问另一个控制器但不工作
- javascript - Indesign 查找不在整个文档中的文本