简体   繁体   中英

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".

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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