简体   繁体   中英

EXCEL VBA: How to manupulate next cell's (same row) value if cell.value=“WORD” in a range

I want to change the next cell in same row in a if cell.value="word" in a range. I have defined the range, using 'for' loop. In my code,

if cell.value="FOUND THE CELL" then
cell.value+1="changed the next right side cell"
cell.value+2="changed the second right side cell"
end if

I know this is wrong. How can we do it?

If cell.Value2 = "FOUND THE CELL" Then
    cell.Offset(0, 1).Value2 = "changed the next right side cell"
    cell.Offset(0, 2).Value2 = "changed the second right side cell"
End If

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