Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
separator of thousands | Excel Discussion (Misc queries) | |||
How do I default separator for thousands when working in XLS in t. | Excel Worksheet Functions | |||
Convert a number to text and add a comma separator for thousands | Excel Programming | |||
thousands comma separator in VBA | Excel Discussion (Misc queries) | |||
separator of thousands | Excel Discussion (Misc queries) |