Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this For Each statement?
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this For Each statement?
I don't think I've seen an Error 13 before. Does this help?
http://support.microsoft.com/kb/821292 That IIF looks like something from Access-world. Maybe this will help: http://www.access-programmers.co.uk/...ad.php?t=88805 Good luck, Ryan--- -- Ryan--- If this information was helpful, please indicate this by clicking ''Yes''. "Ryan M-J" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this For Each statement?
Thanks!
I thought it retuned a cell reference, not the value of the cell. Ryan "Jim Cone" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
What's wrong with this if statement? | Excel Discussion (Misc queries) | |||
can someone please tell me what i did wrong with this if statement? | Excel Programming | |||
IF Statement help please - again - got it wrong last time! | Excel Worksheet Functions | |||
wts wrong with this statement | Excel Worksheet Functions | |||
What is wrong with this IF statement? need help. | Excel Discussion (Misc queries) |