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.
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.