LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to insert the Thousands Separator (comma) in Excel?

Hello all.

I've got a VBScript that takes a CSV file, makes some formatting
changes, and saves it to an XLS file. What I'd like to add to this
script is the command to insert the Thousands Separator in column B
for the entire column. Column B contains numbers in every cell except
for the top cell which has a word.

In searching I did find the Constant "Const xlThousandsSeparator = 4"
but I can't quite figure out how to write the line to implement it.

Any suggestions would be greatly appreciated. Thanks!

My script:

Const xlDescending = 2
Const xlNormal = 1
Const xlCenter = -4108

Set objFSO = CreateObject("Scripting.FileSystemObject")

Dim CurDir
CurDir = objFSO.GetFolder(".").Path
Set Folder = objFSO.GetFolder(CurDir)
Set Folder = nothing

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Open(CurDir & "\Results.csv")
Set objWorksheet = objWorkbook.Worksheets(1)

'~~ Sort by Column B, Descending
Set objRange = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("B1")
objRange.Sort objRange2,2

'~~ Insert blank row at Row 1
sRow = "1"
objExcel.Worksheets(1).Rows(sRow).Insert xlDown

'~~ Insert Header text
objExcel.Worksheets(1).Cells(1,1).Value = "Server"
objExcel.Worksheets(1).Cells(1,2).Value = "Error Amount"

'~~ Bold the Header row
Set objRange3 = objExcel.Range("A1:B1")
objRange3.Font.Bold = True

'~~ Auto Fit and Center both Columns
objExcel.Cells.EntireColumn.AutoFit
objExcel.Cells.EntireColumn.HorizontalAlignment = xlCenter

'~~ Insert blank row at Row 2
sRow = "2"
objExcel.Worksheets(1).Rows(sRow).Insert xlDown

objWorkbook.SaveAs CurDir & "\Results.xls",1

objWorkbook.Close
objExcel.Quit

Set objFSO = nothing
Set objExcel = nothing
Set objWorkbook = nothing
Set objWorksheet = nothing
Set objRange = nothing
Set objRange2 = nothing
Set objRange3 = nothing

 
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
separator of thousands Antonio Excel Discussion (Misc queries) 0 April 4th 08 01:28 AM
How do I default separator for thousands when working in XLS in t. Kamal Singh Oberh Excel Worksheet Functions 3 April 30th 07 07:20 AM
Convert a number to text and add a comma separator for thousands prahz Excel Programming 2 December 7th 06 06:19 PM
thousands comma separator in VBA Wendy Francis Excel Discussion (Misc queries) 2 October 25th 05 01:14 AM
separator of thousands excelFan Excel Discussion (Misc queries) 2 December 27th 04 12:27 PM


All times are GMT +1. The time now is 07:26 PM.

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

About Us

"It's about Microsoft Excel"