Space function used in a string in VBA is not working

I've tried several ways including making another string that acts as a space, and also just " ".

StrBody2 = "<b>Downtime particulars</b>" & "<br>" & _
           "Short description: " & space(10) & Range("External_Start_Description").Text & "<br>" & "<br>"

I want there to be a space between "Short description" and Range("External_Start_Description").Text, yet there is none.

I expect this has to do with using the range function in the string.

Context: this string is later used in an email with other strings:

        .HTMLBody = "<p><font color=""#112369"" face=""arial"" size=""10px"">" & StrBody & StrBody2 & RangetoHTML(rng) & StrBody3

2 Answers

0
Kyle On

All you need to do is put quotes with a space in your concatenation like below:

StrBody2 = "<b>Downtime particulars</b>" & "<br>" & _
           "Short description: " & " " & Range("External_Start_Description").Text & "<br>" & "<br>"
4
Tim Williams On

HTML collapses runs of multiple spaces to a single space - you need to use the non-breaking space entity &nbsp; if you want a run of spaces.

Replace(space(10), " ", "&nbsp;")