+ Reply to Thread
Results 1 to 2 of 2

Changin Cell Formats using VBA

  1. #1
    Michael
    Guest

    Changin Cell Formats using VBA

    Hey Guys.

    I was wondering if someone could help me.

    I am writing VB code for a budgetary and forecasting tool. I have the code
    written to do the analysis, and then create a summary table with all the
    information in it. However, the cells are formatted correctly so each time I
    run it, I have make some cosmetic changes. I know you can do this using VB,
    but I do not know how.

    I need to:
    - Change the format of a range from a number to currency.
    - Change the format of a range from a number to a percentage.
    - Add all around borders for a range.

    I greatly appreciate any assistance you could provide.

    Thanks,

    -Michael

  2. #2
    Gary''s Student
    Guest

    RE: Changin Cell Formats using VBA

    Using the Macro Recorder:


    Sub Macro2()
    Range("G1").Select
    Selection.NumberFormat = "$#,##0.00"
    Range("G2").Select
    Selection.NumberFormat = "0.00%"


    Range("G1:G2").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    End Sub
    --
    Gary's Student


    "Michael" wrote:

    > Hey Guys.
    >
    > I was wondering if someone could help me.
    >
    > I am writing VB code for a budgetary and forecasting tool. I have the code
    > written to do the analysis, and then create a summary table with all the
    > information in it. However, the cells are formatted correctly so each time I
    > run it, I have make some cosmetic changes. I know you can do this using VB,
    > but I do not know how.
    >
    > I need to:
    > - Change the format of a range from a number to currency.
    > - Change the format of a range from a number to a percentage.
    > - Add all around borders for a range.
    >
    > I greatly appreciate any assistance you could provide.
    >
    > Thanks,
    >
    > -Michael


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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