Looping with more than one condition

  • Thread starter Carrie_Loos via OfficeKB.com
  • Start date
C

Carrie_Loos via OfficeKB.com

I have a very large spreadsheet that loops through cells and updates them if
they are blank. I have a new conditon to add to that where if the cell is
blank and another is not blank then move to next cell. I'm a little stuck on
how to write that part. Can I put an "And" prior to the Then?

Dim mycell As Range


For Each mycell In Range("TO_Test")
If IsEmpty(mycell) Then
mycell = "something"

End If
Next mycell
 
M

Mike

Sub test2()
Dim mycell As Range
' If TO_Range is in column A
' Offset(0-Rows,1-Columns) will
' check 1 column to the right to if blank
For Each mycell In Range("TO_Test")
If IsEmpty(mycell) And _
IsEmpty(mycell.Offset(0, 1).Value) Then
mycell = "something"
End If
Next mycell
End Sub
 
C

Carrie_Loos via OfficeKB.com

THANK YOU!
Sub test2()
Dim mycell As Range
' If TO_Range is in column A
' Offset(0-Rows,1-Columns) will
' check 1 column to the right to if blank
For Each mycell In Range("TO_Test")
If IsEmpty(mycell) And _
IsEmpty(mycell.Offset(0, 1).Value) Then
mycell = "something"
End If
Next mycell
End Sub
I have a very large spreadsheet that loops through cells and updates them if
they are blank. I have a new conditon to add to that where if the cell is
[quoted text clipped - 9 lines]
End If
Next mycell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top