0

I'm doing some coding in VBA and am pretty new to it all. I would like to send an email using the information stored in a 2D array. Currently, I just send:

Mr ABCD: 123456
Mr EFGHIJ: 789101112
etc...

where Array(0,0) = Mr ABCD, Array(0,1) = 123456, and it's quite ugly given the poor formatting. I would like to make it look slightly more readable, firstly by ensuring that all numeric values are at the same offset, i.e:

Mr ABCD:   123456
Mr EFGHIJ: 789101112
etc...

I have tried simply buffering each name string with a suitable amount of spaces, however the default font does not have equivalently sized characters, so each string may be the same length but not the same size.

So, is there any way to set the string object to have a default font of Courier for example, to ensure all characters are the same size? Preferably this would be done without copying the array into a spreadsheet.

Another question is how would I best craft this into an email that has the same grid format as a spreadsheet, where each grid is of uniform size? Once again, preferably without copying into a spreadsheet. Thank you!

1 Answer 1

2

You need to know html and add tags. So a basic table,

<table>
<thead>
</thead>
<tbody>
<tr><td>cell1</td><td>cell2</td></tr>
<tr><td>cell1</td><td>cell2</td></tr>
</tbody>
</table>

There's lots of formatting you can apply in a few ways. I use CSS normally.

Here's some random example from my harddrive.

<html>
<head>
<style>
TABLE       {font-size: 90%; text-align:left; margin-left:40pt;margin-right:10pt;background-color:lavender;width="90%"}
THEAD       {color: white;font-weight:bold;background-color:darkblue; margin-left:40pt;margin-right:10pt}
TD      {Vertical-Align:Top;cell-padding:3}
</style>
</head>
<body>
    <table>
    <thead>
    </thead>
    <tbody>
    <tr><td>cell1</td><td>cell2</td></tr>
    <tr><td>cell1</td><td>cell2</td></tr>
    </tbody>
    </table>
</body>
</html>
Sign up to request clarification or add additional context in comments.

1 Comment

Cool, thanks for the answer - I'll give it a try and get back to you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.