ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For each....that is not blank (https://www.excelbanter.com/excel-programming/370555-each-not-blank.html)

Aria[_2_]

For each....that is not blank
 
Hello,
How do you change this line to become For Each c in the range of B2 to
B12 that is Not Blank?

For Each c In Sheets("Inventory").Range("B2:B12")

:) Aria

*** Sent via Developersdex http://www.developersdex.com ***

Excelenator[_48_]

For each....that is not blank
 

Code:
--------------------
For Each c In Sheets("Inventory").Range("B2:B12")
If c.value < "" Then
-your code here-
End if
Next c

--------------------


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=572257


Dave Peterson

For each....that is not blank
 
How about just ignore the blanks, but still loop through them:

for each c in sheets("inventory").range("B2:B12").cells
if c.value = "" then
'do nothing, skip it
else
'do the real work here
end if
next c


Aria wrote:

Hello,
How do you change this line to become For Each c in the range of B2 to
B12 that is Not Blank?

For Each c In Sheets("Inventory").Range("B2:B12")

:) Aria

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson

Bernie Deitrick

For each....that is not blank
 
If you know that they are constants (but not "" - those aren't actually blank), you could use:
For Each c In Sheets("Inventory").Range("B2:B12").SpecialCells(x lCellTypeConstants,23)

Or if they are all formulas (but not formulas that return "" - those also aren't actually blank):
For Each c In Sheets("Inventory").Range("B2:B12").SpecialCells(x lCellTypeFormulas,23)

HTH,
Bernie
MS Excel MVP


<Aria wrote in message ...
Hello,
How do you change this line to become For Each c in the range of B2 to
B12 that is Not Blank?

For Each c In Sheets("Inventory").Range("B2:B12")

:) Aria

*** Sent via Developersdex http://www.developersdex.com ***




Aria[_2_]

For each....that is not blank
 
Thanks Excelenator, that's exactly what I needed. Thanks to Dave also.
How do you set another condition that for each d in C2 to C12 that
matches to $A$1, then afterwards trigger this code?

For Each c In Sheets("Inventory").Range("B2:B12")
If c.value < "" Then
-your code here-
End if
Next c

:) Aria


*** Sent via Developersdex http://www.developersdex.com ***

Excelenator[_50_]

For each....that is not blank
 

Something like this???



Code:
--------------------
For Each d in Sheets("Inventory").Range("C2:C12")
IF d.value = Range("A1").Value Then
For Each c In Sheets("Inventory").Range("B2:B12")
If c.value < "" Then
-your code here-
End if
Next c
Next d
--------------------


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=572257


Aria[_2_]

For each....that is not blank
 
Yes, thank-you Excelenator! That's exactly what I needed.
:) Aria



*** Sent via Developersdex http://www.developersdex.com ***


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

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