+ Reply to Thread
Results 1 to 5 of 5

Draw a border based on current month

Hybrid View

  1. #1
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Draw a border based on current month

    I have a spread sheet with the months across the columns and data down the rows. I want to write some code within my macro to have a dashed red line drawn down the right side of all the rows of the current month. How would I do this? Thank you!

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,662

    Re: Draw a border based on current month

    With Months in A1- L1. Select columns A - L, then
    Use Conditional Formatting:

    =Month(A$1)=Month(Now())
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Draw a border based on current month

    Being so new to VBA I am having some trouble with what you have said to do. I have the months in cells C5-N5 and this is what I want it to do when it finds the correct month based on today's date (sept).

    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlDash
    .Color = -16776961
    .TintAndShade = 0
    .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone

  4. #4
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Draw a border based on current month

    Here is a modified version of what I am working with. As you can see the red dashed line is to the right of August. I am trying to have code put into my macro that will automatically move that line to the right of September so that I don't have to manually change the cell references in the code every month.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,662

    Re: Draw a border based on current month

    Maybe:
    Option Explicit
    Private Sub Worksheet_Activate()
        Dim MonthColumn As Long, _
            LastRow As Long, _
            Temp As Long
            
            MonthColumn = Month(Now()) + 1
            LastRow = 17
        With Range(Cells(2, MonthColumn), Cells(LastRow, MonthColumn))
            .Borders(xlEdgeLeft).LineStyle = xlNone
            With .Borders(xlEdgeRight)
                .Weight = xlMedium
                .LineStyle = xlDash
                .Color = vbRed
            End With
        End With
        For Temp = 5 To 17 Step 4
            With Cells(Temp, MonthColumn).Borders(xlEdgeBottom)
                .Weight = xlMedium
                .LineStyle = xlContinuous
                .Color = vbBlack
            End With
        Next Temp
    End Sub
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Determine work days in current month or next month based on day of the month
    By sbrnard in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-29-2014, 05:14 PM
  2. Pivot table draw border based on order number
    By Risto85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2014, 08:56 AM
  3. [SOLVED] Pick a cell containing current month actulas based what the current month is.
    By vanbasten007 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-10-2014, 01:17 AM
  4. [SOLVED] Help with a system to auto populate month names based on current month
    By rosboy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-01-2012, 05:17 PM
  5. create border across entire row based on current week
    By sentofuno in forum Excel General
    Replies: 8
    Last Post: 01-22-2008, 09:03 AM

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