+ Reply to Thread
Results 1 to 2 of 2

Code to add a line based on date

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

    Code to add a line based on date

    I am trying to add a dashed line to a certain section of a column based on the current month. I have the months starting at C5 (JAN) and going D5 (FEB) E5 (MAR) and so on and I have the year merged and centered above the 12 months. I need the macro to know that it is currently MAY of 2014 so I need the code to put the dashed line on the left side of the column. Here is what I currently have and as you can see I have just put the column in there of where I want the line to go but I don't want to have to go in manually and change it every month. Any help would be greatly appreciated.


    Range("G5:G40").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlDash
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Last edited by JT_2111; 05-19-2014 at 04:26 PM.

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

    Re: Code to add a line based on date

    I think basically I just need a variable that recognizes the current month then finds the column for that month and adds the line to it.

+ 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. Replies: 2
    Last Post: 10-06-2013, 02:03 PM
  2. Formulating Date cells to auto color code based on Date
    By darren.capps in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-23-2013, 02:08 PM
  3. Depreciation Straight line Calculation based on start and end date
    By anjoseph9626 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-03-2013, 04:44 PM
  4. Straight Line Formula based on exact date of purchase
    By cawinkel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-07-2012, 06:24 PM
  5. Count Line Items Based on Date
    By bantadant in forum Excel General
    Replies: 2
    Last Post: 12-21-2010, 10:18 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