+ Reply to Thread
Results 1 to 7 of 7

Format of Number

  1. #1
    Registered User
    Join Date
    03-19-2015
    Location
    Lahori
    MS-Off Ver
    Windows 7
    Posts
    17

    Format of Number

    Hi,

    I am fetching data from the ADO connection to my excel cell using code
    Please Login or Register  to view this content.
    Here while displaying my table having 0.00 as value is changes to 0, how can i retain its format when displayed in VBA?

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Format of Number

    You can add a line of code, something like

    Selection.NumberFormat = "#,##0.00"

    Change the Selection Part to the way you would want to refer to the range..

    There are many different ways.. This is just one of it.
    Last edited by NeedForExcel; 06-02-2015 at 02:30 AM.
    Cheers!
    Deep Dave

  3. #3
    Registered User
    Join Date
    03-19-2015
    Location
    Lahori
    MS-Off Ver
    Windows 7
    Posts
    17

    Re: Format of Number

    For this i feel i have to format a precise cells, where as my data place can be changed tomorrow as table column adds. Is there any general way of doing it?

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Format of Number

    You can then include it in the FOR Loop Which you have up there..

    That should be feasible?

    Something like -

    Please Login or Register  to view this content.
    Note: Not very sure which cells actually need to be formatted as 0.00..
    Last edited by NeedForExcel; 06-02-2015 at 02:42 AM.

  5. #5
    Registered User
    Join Date
    03-19-2015
    Location
    Lahori
    MS-Off Ver
    Windows 7
    Posts
    17

    Re: Format of Number

    Here is the code i added:

    Please Login or Register  to view this content.
    After finding the field data type it will be easier to format as you suggested.

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Format of Number

    True!

    So did it work?

  7. #7
    Registered User
    Join Date
    03-19-2015
    Location
    Lahori
    MS-Off Ver
    Windows 7
    Posts
    17

    Re: Format of Number

    Indeed... more info can be get from "https://support.microsoft.com/en-us/kb/193947"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need formula or code to convert number(s) from custom format to number format
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2015, 07:44 PM
  2. How to change a - number format to a positive number format ?
    By leanne2011 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2011, 10:14 AM
  3. Replies: 1
    Last Post: 05-18-2006, 11:45 PM
  4. Replies: 2
    Last Post: 11-11-2005, 09:05 AM
  5. Number format based on number format of another cell in another workbook
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-09-2005, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1