Question

I would like to know how to separate email addresses in the following code:

With OutApp.CreateItem(0)
If cel.Value <> "" Then
.To = cel.Value
.CC = cel.Offset(0, 10).Value & cel.Offset(0, 11).Value
.Body = strbody & vbNewLine & vbNewLine & Signature

In the CC field when the macro is run it does populate the fields but like this: CC: will@me.comother@mail.com and it should be like this CC: will@me.com; other@mail.com

Any ideas on how to solve this? I have already tried: cel.Offset(0, 10).Value & ";" & cel.Offset(0, 11).Value but no luck

Était-ce utile?

La solution

This was fixed like this cel.Offset(0, 10).Value & " ; " & cel.Offset(0, 11).Value and its working now

Autres conseils

Consider something more dynamic:

join(worksheetfunction.Transpose(range("A1:A4")),";")

This way you can programatically change the range and it will just join as many rows as you have. The method you have chosen means there must always be 2 people (and ONLY 2 people) to CC.

Range("A1:A4") gets the range of data, Transpose will swap it from a top to bottom orientation to a left to right scenario (making it an array), the Join function joins all elements of an array using the supplied delimiter (in this case ";")

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top