Adding a comma after an int field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a simple .xls worksheet with some VB code, spitting out a text file
when you click a button to execute the code.

I have int fields that I calculate as I create the file and at the end, I
write the values of these fields to a trailer record.

That all works OK, but now the requirement is to have a comma after the int
value, so instead of having

TOTALNUMBER=12
TOTALVALUE=12345

it should be
TOTALNUMBER=12,
TOTALVAULUE=12345,

If I simply append a comma, I get this

TOTALNUMBER=12 , <--- trailing spaces
TOTALVALUE=12345 , <-- trailing spaces

I've tried formatting it like this
.transTotal = Format(Worksheets("Setup-tlr").Cells(30, 2).value, "######0")

and then appending the comma but that does not work either. I tried adding a
',' to the mask (######0,) but that returns a zero value always.

I appreciate any help - thanks!
Bennie
 
One way:

.transtotal = Format(Trim( _
Worksheets("Setup-tir").Cells(30, 2).Text), "######0\,")
 
Thanks to all who responded.

I ended up using a free cell with a formula like

=A1&","

which did the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top