Results 1 to 8 of 8

VBA If Statement Formatting

Threaded View

  1. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA If Statement Formatting

    Hi @TMShucks, thank you for taking the time to reply to my post, and my apologies for the typo.

    The original code should have been:

    Sub MonthlyFormat()
        
        Dim LastRow As Long
        Dim ws As Worksheet
        
        Const StartRow As Long = 5
        
        For Each ws In Worksheets(Array("Monthly Direct", "Monthly Enhancements", "Monthly Indirect", "Monthly Overheads", "Monthly Projects"))
            With ws.Range("B2")
                .Value = "Monthly Actuals Used"
            End With
                
            With ws.Range("B3")
                .Value = Evaluate("EoMonth(Today(), -2) + 1")
                .NumberFormat = "mmm yy"
                .HorizontalAlignment = xlCenter
                .Interior.ColorIndex = 37
                    With .Font
                        .Name = "Lucida Sans"
                        .Bold = True
                        .Size = 10
                    End With
            End With
            
            With ws.Range("B2, B5, G5")
                .HorizontalAlignment = xlCenter
                .Interior.ColorIndex = 11
                    With .Font
                        .Name = "Lucida Sans"
                        .Bold = True
                        .Size = 11
                        .ColorIndex = 2
                    End With
            End With
            
               
            If ws.Value = Array("Monthly Direct", "Monthly Indirect", "Monthly Overheads") Then
                With ws.Range("B7:D7, G7:K7")
                    .HorizontalAlignment = xlCenter
                    .Interior.ColorIndex = 37
                        With .Font
                            .Name = "Lucida Sans"
                            .Bold = True
                            .Size = 10
                        End With
                End With
            End If
        Next ws
    End Sub
    All the best and kind regards
    Last edited by hobbiton73; 01-19-2014 at 11:09 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formatting cells with an IF statement
    By Little mag in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-22-2013, 07:46 AM
  2. Conditional Formatting (IF statement)
    By Marmie2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-09-2013, 11:39 PM
  3. Conditional Formatting/IF statement Help
    By DayHey23 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2013, 12:37 PM
  4. IF statement using formatting criteria (NOT conditional formatting)
    By chelseasikoebs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2009, 01:57 AM
  5. IF statement to control formatting?
    By drdavidge in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-24-2008, 05:18 PM

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