+ Reply to Thread
Results 1 to 4 of 4

How to sent for cell: font size=7,text format in VBA

  1. #1
    netx
    Guest

    How to sent for cell: font size=7,text format in VBA

    After I do .Range().Clear I lost "font size" and "text format" in Cells.
    I wonder how to set in VBA:
    - font size for cell
    - formatting "text" for cell
    Excel XP.

    I am not sure about translation of above because I use Polish version of
    Excel.

    Thanks for help,

    Mark



  2. #2

    Re: How to sent for cell: font size=7,text format in VBA

    Mark -

    Why not try running your macro recorder and looking at the code
    afterwards? I put information in cell I18 and then changed the format
    (e.g. italics, fontsize, borders, etc.). Here's what the code looks
    like (in English). I also tested it - it works.

    Sub Macro1()
    Range("I18").Select
    With Selection.Font
    .Name = "AngsanaUPC"
    .FontStyle = "Italic"
    .Size = 24
    .Strikethrough = True
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleDouble
    .ColorIndex = xlAutomatic
    End With
    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
    With Selection.Interior
    .ColorIndex = 42
    .Pattern = xlGray50
    .PatternColorIndex = xlAutomatic
    End With
    End Sub

    netx wrote:

    > After I do .Range().Clear I lost "font size" and "text format" in Cells.
    > I wonder how to set in VBA:
    > - font size for cell
    > - formatting "text" for cell
    > Excel XP.
    >
    > I am not sure about translation of above because I use Polish version of
    > Excel.
    >
    > Thanks for help,
    >
    > Mark



  3. #3

    Re: How to sent for cell: font size=7,text format in VBA

    PS. Here's the code for pasting the formats from another cell: Put
    the cursor on the cell that has the formatting you want, and the
    following macro will copy those text formats into the new cell (I17)

    Sub Macro2()
    '
    ' Macro2 Macro
    ' Macro recorded 8/8/2005 by Jim Shoenfelt
    '

    '
    Selection.Copy
    Range("I17").Select
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    End Sub


  4. #4
    Dave Peterson
    Guest

    Re: How to sent for cell: font size=7,text format in VBA

    Maybe you want .range().clearcontents

    That just erases the contents from the cell--like hitting the delete key.



    netx wrote:
    >
    > After I do .Range().Clear I lost "font size" and "text format" in Cells.
    > I wonder how to set in VBA:
    > - font size for cell
    > - formatting "text" for cell
    > Excel XP.
    >
    > I am not sure about translation of above because I use Polish version of
    > Excel.
    >
    > Thanks for help,
    >
    > Mark


    --

    Dave Peterson

+ 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