简体   繁体   中英

Excel VBA, Checking for value from a cell in the same row

I have a macro that needs to check if there is a 1 in a cell from the same row. The problem I have is that I need to do that for a range of 3 columns.

Actually, this part doesn't work at all but I can put it in cells form.

I need to check for all the cells from ("P3:R" & iNbKids) if there is a 1 in the cell ("K" & ActiveCell.Row). I have tried a lot of things but I can't seem to figure it out.

iNbKids is an Integer

Hard to say for sure, but it looks like you need to change

If Cell.Value <> 0 Then

To

If Range("K"&r2.row).Value <> 0 Then

Or

If Range("K"&r2.row).Value = 1  Then

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