ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combining Fors and Ifs (https://www.excelbanter.com/excel-programming/407742-combining-fors-ifs.html)

Sandy

Combining Fors and Ifs
 
Is it possible to combine the following :-

For Each MyCell In Sheets("Current Round Detailed").Range("C10:K10")
If (MyCell.Value 0 And MyCell.Offset(12).Value = vbNullString) Or
_
(MyCell.Value 1 And MyCell.Offset(14).Value = vbNullString)
Then

MsgBox "xxxxxxxxx"

Exit Sub
End If
Next MyCell

For Each MyCell In Sheets("Current Round Detailed").Range("C16:K16")
If (MyCell.Value 0 And MyCell.Offset(17).Value = vbNullString) Or
_
(MyCell.Value 1 And MyCell.Offset(19).Value = vbNullString)
Then

MsgBox "yyyyyyyyyyy"

Exit Sub
End If
Next MyCell

into something along the lines of :-

If
For Each MyCell In Sheets("Current Round Detailed").Range("C10:K10")
If (MyCell.Value 0 And MyCell.Offset(12).Value = vbNullString) Or
_
(MyCell.Value 1 And MyCell.Offset(14).Value = vbNullString)
End If
Next MyCell

Or

For Each MyCell In Sheets("Current Round Detailed").Range("C16:K16")
If (MyCell.Value 0 And MyCell.Offset(17).Value = vbNullString) Or
_
(MyCell.Value 1 And MyCell.Offset(19).Value = vbNullString)
End If
Next MyCell
Then "zzzzzzzzzzzzzzzz"

Thanks in advance
Sandy



All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com