简体   繁体   English

Excel 根据其原始值和另一个单元格值更改单元格文本

[英]Excel change a cell text based on it's original value and another cells value

I've tried myself and have been failing miserably over the last couple days to accomplish.我已经尝试过自己,并且在过去的几天里一直以失败告终。

Need a Macro to check Column A full range, for a specific value "ZP" and if true, then check column C in those rows and if that value starts with a "Z" then change column A cell in that row to "ZPAC".需要一个宏来检查 A 列的完整范围,对于特定值“ZP”,如果为真,则检查这些行中的 C 列,如果该值以“Z”开头,则将该行中的 A 列单元格更改为“ZPAC” .

This will get it done这将完成它

Sub ZPtoZPAC()
    For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
        If Cells(i, "A").Value = "ZP" Then
            If Left(Cells(i, "C").Value, 1) = "Z" Then
                Cells(i, "A").Value = "ZPAC"
            End If
        End If
    Next i
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM