Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding a comma after an int field

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Adding a comma after an int field

Cells(30,2).NumberFormat = "General,"
--
Gary''s Student


"Bennie" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding a comma after an int field


try adding <original line & ","

regards


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=519128

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Adding a comma after an int field

One way:

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


In article ,
Bennie wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding a comma after an int field

Thanks to all who responded.

I ended up using a free cell with a formula like

=A1&","

which did the trick.
--
Appreciated.
Bennie


"Bennie" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLookup Method for Comma Delimited Field DoveArrow Excel Discussion (Misc queries) 1 December 22nd 11 12:59 PM
How to save data in CSV format when a field also contains comma? V.R. Excel Discussion (Misc queries) 0 April 10th 06 09:58 AM
CSV file with Comma in text Field GHopson Excel Programming 4 February 22nd 06 03:54 PM
adding a single quote and comma to every cell in Excel rodsheffield Excel Programming 3 October 4th 05 08:17 PM
Formula for adding a comma in front of text in a cell Shelley Excel Worksheet Functions 4 April 18th 05 04:34 PM


All times are GMT +1. The time now is 06:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"