Results 1 to 5 of 5

Make row that automatically adds newest month + 2 nearest future months

Threaded View

  1. #1
    Registered User
    Join Date
    08-01-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    7

    Make row that automatically adds newest month + 2 nearest future months

    I have a row with months in the format Jan-14 (01-01-2014), Feb-14 (01-01-2014) and so on, starting from column 3. I want the row to automatically update such that it contains the months from Jan-14 to the present month + two months. That is, since today's date is 25-08-2014, the row should contain the months Jan-14,...., Aug-14 (01-08-2014), Sept-14 (01-09-2014) and Oct-14 (01-10-2014). I have tried to do the following code but it is currently not working. Any suggestions how to make this work?

    Sub Updatemonths()
    Dim col As Long
    Dim lc As Variant
    lc = Worksheets("Summary").Cells(4, Worksheets("Summary").Columns.Count).End(xlToLeft).Column
        Dim StartD As Date, EndD As Date
        StartD = Worksheets("Summary").Cells(4, lc)
        EndD = Date
        For col = 1 To (EndD - StartD)
        If IsDate(Cells(4, lc + col)) Then
            Worksheets("Summary").Cells(4, lc + col).Value = DateSerial(Year(Cells(4, StartD + col)), Month(Cells(4, lc + col)), 1)
        End If
        Next col
    End Sub
    Best regards

    Christian Ulrich
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 04-09-2014, 08:13 AM
  2. [SOLVED] Calculate future date to nearest Monday
    By mswauger in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-09-2013, 04:13 PM
  3. Replies: 1
    Last Post: 11-22-2011, 08:11 AM
  4. Replies: 4
    Last Post: 05-23-2011, 09:15 AM
  5. Counting dates for a the present month but not future months
    By BrianInCalifornia in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-06-2005, 10:15 PM

Tags for this Thread

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