Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:37:44+00:00 2026-06-10T23:37:44+00:00

I want to modify the column’s number format automatically in excel. Set excel =

  • 0

I want to modify the column’s number format automatically in excel.

Set excel = CreateObject("Excel.Application")
Set oWB = excel.Workbooks.Open("E:\Docs\Invoice.csv")

/* Excel Macro starts */
Columns("G:G").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("H:H").Select
Selection.NumberFormat = "0.00"
/* Excel Macro ends */

oWB.save
oWB.Application.Quit

I run this .vbs using command line. Excel doc does not get updated.
Could anyone please help me in resolving this issue ?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:37:46+00:00Added an answer on June 10, 2026 at 11:37 pm

    What you are missing in the above code is you are not fully qualifying the Excel Objects.

    How would vbs understand what is Columns("G:G")?

    Try this

    Dim objXLApp, objXLWb, objXLWs
    
    Set objXLApp = CreateObject("Excel.Application")
    Set objXLWb = objXLApp.Workbooks.Open("E:\Docs\Invoice.csv")
    
    '~~> Working with Sheet1
    Set objXLWs = objXLWb.Sheets(1)
    
    With objXLWs
        '/* Excel Macro starts */
        .Columns("G:G").NumberFormat = "m/d/yyyy"
        .Columns("H:H").NumberFormat = "0.00"
        '/* Excel Macro ends */
    End With
    
    objXLWb.Save
    objXLWb.Close (False)
    
    Set objXLWs = Nothing   
    Set objXLWb = Nothing
    
    objXLApp.Quit
    Set objXLApp = Nothing
    

    EDIT: My Only concern is that the numberformat will not stay as it is a CSV file. You might want to save it as an Excel file?

    CODE

    Dim objXLApp, objXLWb, objXLWs
    
    Set objXLApp = CreateObject("Excel.Application")
    
    objXLApp.Visible = True
    
    Set objXLWb = objXLApp.Workbooks.Open("E:\Docs\Invoice.csv")
    
    '~~> Working with Sheet1
    Set objXLWs = objXLWb.Sheets(1)
    
    With objXLWs
        .Columns("G:G").NumberFormat = "m/d/yyyy"
        .Columns("H:H").NumberFormat = "0.00"
    End With
    
    '~~> Save as Excel File (xls) to retain format
    objXLWb.SaveAs "C:\Sample.xls", 56
    
    '~~> File Formats
    '51 = xlOpenXMLWorkbook (without macro's in 2007-2010, xlsx)
    '52 = xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007-2010, xlsm)
    '50 = xlExcel12 (Excel Binary Workbook in 2007-2010 with or without macro's, xlsb)
    '56 = xlExcel8 (97-2003 format in Excel 2007-2010, xls)
    
    objXLWb.Close (False)
    
    Set objXLWs = Nothing
    Set objXLWb = Nothing
    
    objXLApp.Quit
    Set objXLApp = Nothing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to modify (Remove all white spaces) all the values of Column Name
I want to modify a connection string that's hard-coded in a Java application (jar
Currently I have a column that is declared as a NUMBER. I want to
I have a list of 3 columns: 2547123456789,5391074043372870,639027123456789 I want to modify second column
I want to modify a PDF document with PHP. I found the libs FPDF
I want to modify something in Settings.secure database, just as the android Settings app
I want to modify the solution for highlighting trailing whitespace described here by NOT
I want to modify some code in the Eclipse JDT itself (In the Debug
I want to modify a view from Action Helper in Zend Framework in preDispatch()
I want to modify my table view cell apparence when the delete button came

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.