Formula Help

Joined
Jan 11, 2012
Messages
2
Reaction score
0
Right now I'm using the following formula to grab a range of cells and put them into one cell with commas between and it excludes blank cells. It works great. However, I can't figure out how to have it include two different ranges in the same cell.



Function myConCat(S As Range) As String
Dim cell As Range
Dim con As String
Dim I As Integer
I = 1
For Each cell In S
If I = 1 Then
con = cell
ElseIf cell <> "" Then
con = con & ", " & cell
End If
I = I + 1
Next cell
myConCat = con
End Function


For instance: If I type =myConCat(C5:C11) it does the above function no problem.
What do I do if I want C5:11 and C20:28 in the same cell separated by commas?

Thanks in advance.
 

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

Top