Results 1 to 3 of 3

Thread: Help with formatting methods?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    1

    Help with formatting methods?

    Hi there,

    I'm very new at this so please bear with me....

    I'm trying to find a method to color the background cells in my worksheet, format a cell so that it displays the date in the following format: "Nov-2005", and finally to format the number of decimal places displayed in some selected cells. Any ideas?

    For the date problem, I'm not sure if I'm on the right track :

    .range("A1").numberformat = " ????? "

    Similarly for the decimal places prob, should I be using the .numberformat method??

    Any help would be appreciated.

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Help with formatting methods?

    Quote Originally Posted by Beaver
    I'm trying to find a method to color the background cells in my worksheet
    To set the background colour to red...
    VB Code:
    1. Range("A1").Interior.ColorIndex = 3

    Quote Originally Posted by Beaver
    ...format a cell so that it displays the date in the following format: "Nov-2005",...
    VB Code:
    1. Range("A1").NumberFormat = "mmm-yyyy"

    Quote Originally Posted by Beaver
    ...to format the number of decimal places displayed in some selected cells.
    Examples
    for 2 decimal places with commas use
    VB Code:
    1. Range("A1").NumberFormat = "#,##0.00"

    for 3 decimal places without commas
    VB Code:
    1. Range("A1").NumberFormat = "0.000"

    Just change the range reference to which ever cells you need to format.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Help with formatting methods?

    I don't know if you've discovered this yet or not, but just in case not, here are a couple of examples of referencing cells programatically:
    Code:
    Option Explicit
    Sub Macro1()
        Dim aRow As Long
        Dim aColumn As Long
        
        aRow = 2
        aColumn = 3
        Cells(aRow, aColumn).Interior.ColorIndex = 3  'Cell C2
        ' -- or like this --
        Cells(3, "B").Value = "TEST"    'Cell B3
    End Sub
    Good Learning and Good Programming!
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

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



Click Here to Expand Forum to Full Width