Consulting

Results 1 to 4 of 4

Thread: Solved: Changing NumberFormat

  1. #1
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location

    Solved: Changing NumberFormat

    I am inserting stuff into some cells as follows:

    shtExcel.Range(Cells(i, 1), Cells(i, 5)) =  Split(strBuffer, vbTab)
    Then, I am trying to change some of the cells to numeric format.
    What do I need to use instead of the following?

    shtExcel.Range(Cells(i, 2), Cells(i + j,3)).NumberFormat = "#,##0.00"

  2. #2
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    It seems that I need to do the equivalent of "Convert To Number", before doing the formatting, but I have not yet found that in the Excel object model.

  3. #3
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Hey Howard, here's your answer.

    Add code like the following before setting the format.
     		For Each rngCell In shtExcel.Range(Cells(lngFormat, 2),  Cells(lngFormat + lngHigh, 3))
    			rngCell.Value =  rngCell.Value
    		Next rngCell
    This converts the cells from text to numeric format.

  4. #4
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Thanx Howard!
    Knew I could count on you!

Posting Permissions

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