+ Reply to Thread
Results 1 to 3 of 3

Need help with code!! Font is not changing for all the data on the worksheet

Hybrid View

daillest319 Need help with code!! Font is... 01-13-2012, 12:39 PM
JieJenn Re: Need help with code!!... 01-13-2012, 12:42 PM
daillest319 Re: Need help with code!!... 01-13-2012, 12:58 PM
  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Need help with code!! Font is not changing for all the data on the worksheet

    I need the font to be Times New Roman for all the date and i also need the all the data center align. not sure what im doing wrong.



    
    
    Sub format_worksheets()
      Dim i As Long
      Dim LC As Long
      
      
      Application.ScreenUpdating = False
      
      
      For i = 1 To Worksheets.Count
    
    
        'Align Text
         With Selection
            .HorizontalAlignment = xlCenter
            Rows("1").HorizontalAlignment = xlLeft
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .ShrinkToFit = False
         End With
    
    
        ' Format Font
         With Selection.Font
            .Name = "Times New Roman"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
            Rows("2:2").Select
            ActiveWindow.FreezePanes = True
    
         End With
        
        
        
      Next i
      Application.ScreenUpdating = True
      
    End Sub
    Last edited by daillest319; 01-13-2012 at 12:58 PM.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Need help with code!! Font is not changing for all the data on the worksheet

    You get an error when excel does not what "selection" is referring to. Try


    Sub Macro1()
    Dim i As Long
    
    For i = 1 To Sheets.Count
        With Sheets(i).Select
            With Cells
            .Font.Name = "Times New Roman"
            .HorizontalAlignment = xlCenter
            End With
        End With
    Next i
    
    End Sub
    Last edited by JieJenn; 01-13-2012 at 12:45 PM.

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Need help with code!! Font is not changing for all the data on the worksheet

    Thank you worked perfect.

+ 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