# Combine 2 var into 1 string with & in between

#### bumbum2812

##### New Member
Use
VBA Code:
``If IsArray(Ary) Then .Subject ="Hello -"& Join(Ary, "&") Else .Subject= "Hello -" & Ary``
Thank you so much, this will work if i move the code inside my sub to send email.
Good day to you Sir !

### Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

#### Fluff

##### MrExcel MVP, Moderator
Glad to help & thanks for the feedback.

#### bumbum2812

##### New Member
Hi Fluff,

Can you help to write a code like this in VBA & able to put in .subject for outlook & it can show apply for single Ary as well.

=IFS(LEN(Join(Ary, "&"))>200,"Multiple Jobs",LEN(Join(Ary, "&"))<200,Join(Ary, "&")

#### Fluff

##### MrExcel MVP, Moderator
VBA Code:
``````   If IsArray(Ary) Then
txt = Ary
ElseIf Len(Join(Ary, "&")) > 200 Then
txt = "Multiple jobs"
Else
txt = Join(Ary, "&")
End If
.Subject = txt``````

#### bumbum2812

##### New Member
VBA Code:
``````   If IsArray(Ary) Then
txt = Ary
ElseIf Len(Join(Ary, "&")) > 200 Then
txt = "Multiple jobs"
Else
txt = Join(Ary, "&")
End If
.Subject = txt``````
Hi, i replace this with yours but it returns blank.
If IsArray(Ary) Then .Subject ="Hello -"& Join(Ary, "&") Else .Subject= "Hello -" & Ary

#### Fluff

##### MrExcel MVP, Moderator
Is there anything in the array?

#### bumbum2812

##### New Member
Is there anything in the array?
Hi,yes it has data in the array, i have tried to modify as below, it's work for > & < condition but dont work for only Ary. Can you have a look please.

If Len(Join(Ary, "&")) > 200 Then
.Subject = "Multiple jobs"
ElseIf Len(Join(Ary, "&")) < 200 Then
.Subject = " " & Join(Ary, " & ")
ElseIf IsArray(Ary) Then
.Subject = Ary
End If

#### Fluff

##### MrExcel MVP, Moderator
You need to keep it in the order I showed, other it will fail if the array only has one value.

#### bumbum2812

##### New Member
You need to keep it in the order I showed, other it will fail if the array only has one value.
I keep it in order like below, but it return blank

With Sheets("Re-Open")
Ary = Application.Transpose(.Range("A5", .Range("A" & Rows.Count).End(xlUp)).Value)
End With

If IsArray(Ary) Then
txt = Ary

ElseIf Len(Join(Ary, "&")) > 200 Then
txt = "Multiple jobs"
Else
txt = Join(Ary, "&")
End If
.Subject = txt

#### Fluff

##### MrExcel MVP, Moderator
Oops, missed the Not
VBA Code:
``````   If Not IsArray(Ary) Then
txt = Ary
ElseIf Len(Join(Ary, "&")) > 200 Then
txt = "Multiple jobs"
Else
txt = Join(Ary, "&")
End If
.Subject = txt``````