Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Looping with more than one condition

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

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Looping with more than one condition

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

"Carrie_Loos via OfficeKB.com" wrote:

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

--
Message posted via http://www.officekb.com

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Looping with more than one condition

THANK YOU!

Mike wrote:
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


--
Message posted via http://www.officekb.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping and stopping when a condition is met - test april Excel Discussion (Misc queries) 1 October 21st 09 11:36 PM
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
Looping till condition is satisfied? Jo[_2_] Excel Worksheet Functions 3 October 4th 07 09:43 PM
Condition 1 overules condition 2? Bultgren Excel Worksheet Functions 2 January 20th 06 12:29 PM
looping for a condition jhahes[_33_] Excel Programming 1 October 1st 05 12:00 AM


All times are GMT +1. The time now is 07:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"