Wouldn't know what to call it!

  • Thread starter Thread starter 1Fish2Fish
  • Start date Start date
1

1Fish2Fish

I have a "table" that I created. It's just a basic grid with items on the y
axis and items on the x axis (ex. types of fruit on the top, number of fruit
in the basket down the side). I need to pull the numbers of fruit in each
basket, without adding them up, and combine them into one line, separating
each with a comma. (Ex. 3, 4, 5, 6, 7, 8,...). I was able to do that by
using "&", however, if there is no fruit in the basket (0), how can I not
have a comma with a blank space appear until I do have fruit again (ex.
2,3,4,15,16,17,18,19,25 instead of
2,3,4,,,,,,,,,,,,,15,16,17,,,,,,,,,18,,19,,,,,,,25)? I have the possibility
of 144 entries, but also the posibility of only 1 entry. I'm trying to stay
away from an "IF" function because it may end up very involved. Any help is
greatly appreciated. I'm sorry if I didn't explain it well!!
 
Sub ifvaluestring()
For Each c In Selection 'range("a2:a22")
If Len(Application.Trim(c)) > 0 And IsNumeric(c) Then ms = ms & "," & c
Next
MsgBox Right(ms, Len(ms) - 1)
End Sub
 
You could use something like this

=IF(A1="","",A1&", ")&IF(A2="","",A2&", ")&IF(A3="","",A3&",
")&IF(A4="","",A4&", ")&IF(A5="","",A5&", ")&IF(A6="","",A6&", ")&A7



--


Regards,


Peo Sjoblom
 
Don,

Thank you so much for responding. I'm not the best at VBA so I'm getting a
runtime error of "invalid procedure." The line with the error is MsgBox
Right(ms, Len(ms) - 1). Can you assist?
 
Since I didn't know your range I just tested with a selected range of a mix
of numbers and text. Worked just fine. If all else fails, you may send your
workbook to my address below along with snippets of these msgs.
 
Either select a range first or use a range as Don indicated.

For Each c in Range("A2:A22")


Gord Dibben MS Excel MVP
 

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

Back
Top