+ Reply to Thread
Results 1 to 8 of 8

Counting days issue

Hybrid View

  1. #1
    Registered User
    Join Date
    11-14-2014
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    4

    Exclamation Counting days issue

    Hi Folks, new to this forum as I am looking for a solution that has got me stuck.

    The attached sheet shows a number of calendar dates in row A, In column A2:Ax are the number of days that a training course will last, I have a macro that enters the start date of each course, but cannot find a way to add the next day(s) based on the value in Column A.
    The final sheet should look like part two of my attachment.

    I need a macro for this as I have around 200 values in Column A and around 6months worth of training dates in Row A.

    Any assistance will be greatly appreciated.

    IanE
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Counting days issue

    Maybe:

    Sub IanE()
    Dim i As Long
    Dim y As Long
    Dim x As Long
    For i = 2 To Range("A" & Rows.Count).End(3).Row
    y = Cells(i, 1).Value - 1
        For x = 9 To 3 Step -1
            If Cells(i, x).Value <> "" And y >= 1 Then
                Range(Cells(1, x + 1), Cells(1, x + y)).Copy Cells(i, x + 1)
            End If
        Next x
    Next i
                
    End Sub

  3. #3
    Registered User
    Join Date
    11-14-2014
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting days issue

    Hi John,

    Many thanks for the swift reply, and a working solution. Only issue I have is it reporting a "Run Time error 13" Type mis-match after it has completed.
    Any idea?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Counting days issue

    Can you provide a sample workbook (one which produces the error), with some dummy data?

  5. #5
    Registered User
    Join Date
    11-14-2014
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting days issue

    Hi John, Error has gone, once I saved the work book and then re-run the macro it had gone. Thanks
    However I see your solution is only working for the 9 columns as per the sample, I need this to run for "Xn" number of columns,
    is it a case of running a statement to count left on the sheet?

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Counting days issue

    Try:

    Sub IanE()
    Dim i As Long
    Dim y As Long
    Dim x As Long
    For i = 2 To Range("A" & Rows.Count).End(3).Row
    y = Cells(i, 1).Value - 1
        For x = Cells(i, Columns.Count).End(xlToRight).Column To 3 Step -1
            If Cells(i, x).Value <> "" And y >= 1 Then
                Range(Cells(1, x + 1), Cells(1, x + y)).Copy Cells(i, x + 1)
            End If
        Next x
    Next i
                
    End Sub

  7. #7
    Registered User
    Join Date
    11-14-2014
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting days issue

    Hi John, Many thanks for the swift response and solution. Working a treat across my entire sheet.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Counting days issue

    You're welcome. Glad to help out and thanks for the feedback. Please comply with the Forum Rules and mark this thread as solved.

    http://www.excelforum.com/forum-rule...rum-rules.html

+ 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] Counting days issue
    By maddy1980 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-15-2014, 06:05 PM
  2. [SOLVED] Number of days till.. Formula for counting number of days
    By Saturn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-21-2013, 05:46 AM
  3. Counting days
    By nickwilkins in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-06-2013, 03:01 PM
  4. Replies: 9
    Last Post: 09-03-2007, 08:26 PM
  5. [SOLVED] Counting days
    By tinkertron in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-07-2005, 04:09 AM

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