View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default What is wrong with this For Each statement?

The first part of the IIF function must evaluate to either True or False.
So, if "Range("C3").End(xlDown)" contains text the function fails.

Give this a try...
Dim addresses As String
Dim c As Range
For Each c In Range("C3", Cells(Rows.Count, 3).End(xlUp))
If addresses < "" Then
addresses = addresses & ", " & c.Value
Else
addresses = c.Value
End If
Next
--
Jim Cone
Portland, Oregon USA



"Ryan M-J" <Ryan
wrote in message
it throws "Type Mismatch (13)" on the "for each" line only if the range is
strings, numbers work fine, but I need it to be strings

Dim addresses As String
For Each c In IIf(Range("C3").End(xlDown), Range("C3",
Range("C3").End(xlDown)), Range("C3"))
If addresses < "" Then
addresses = addresses & ", " & c.Value
Else
addresses = c.Value
End If
Next