[英]Replacing text based on another cell
I have an employee table with their operation and attendance status.我有一个员工表,上面有他们的操作和出勤状态。 I would like to replace their operation with absent where its listed Sick,Vacation,leave.
我想用缺席替换他们的操作,其中列出了生病,假期,离开。 I had tried some thing similar like in the code below but I lost the code that worked but it only worked a specific cell and not the whole range.
我已经尝试了一些类似于下面代码中的东西,但我丢失了有效的代码,但它只适用于特定的单元格而不是整个范围。 I would like a vba code that will replace column A with absent if a certain condition is met.
我想要一个 vba 代码,如果满足某个条件,它将用不存在替换列 A。 I do know how to do it manually by applying a filter but I would appreciate it if someone can help me with a vba loop where it checks for value in Paycode column and replace their opertion.
我确实知道如何通过应用过滤器手动执行此操作,但如果有人可以帮助我使用 vba 循环来检查 Paycode 列中的值并替换其操作,我将不胜感激。
Thanks谢谢
Sub IF_OR_Test()
For Each Cell In Range("B2:B999")
If Range("B2").Value = "Sick" Then
Range("A2").Value = "Absent"
End If
Next Cell
End Sub
Try this ..试试这个 ..
Sub IF_OR_Test()
dim cl as range
For Each cl In Range("B2:B999")
If cl.Value = "Sick" Then
cl.offset(0,-1).Value = "Absent"
End If
Next cl
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.