+ Reply to Thread
Results 1 to 3 of 3

formula or VBA - would like to autofill cells based on start date and # of months

  1. #1
    jsr
    Guest

    formula or VBA - would like to autofill cells based on start date and # of months

    Hi,
    I am looking for either a formula or code to execute the following:

    Start Month = X
    Number of Months = Y

    and then autofill a row based on the following number of months from
    the start month.

    any suggestions.

    Thanks


  2. #2
    Chip Pearson
    Guest

    Re: formula or VBA - would like to autofill cells based on start date and # of months

    You can do it with VBA as follows:

    Sub CreateMonths(StartMonth As Long, NumMonths As Long, Rng As
    Range)
    Dim Ndx As Long
    For Ndx = StartMonth To StartMonth + NumMonths - 1
    Rng = DateSerial(Year(Now), Ndx, 1)
    Set Rng = Rng(2, 1)
    Next Ndx
    End Sub

    Sub BBB()
    CreateMonths StartMonth:=5, NumMonths:=6, Rng:=Range("a1")
    End Sub



    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "jsr" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I am looking for either a formula or code to execute the
    > following:
    >
    > Start Month = X
    > Number of Months = Y
    >
    > and then autofill a row based on the following number of months
    > from
    > the start month.
    >
    > any suggestions.
    >
    > Thanks
    >




  3. #3
    Arvi Laanemets
    Guest

    Re: formula or VBA - would like to autofill cells based on start date and # of months

    Hi

    P.e. you have in cell B1 start month, entered as any date from this month
    (I'd prefer 1st of month), and formatted as "yyyy mmmm", or "yyyy mmm", or
    "yyyy.mm", and in cell B2 the number of months.

    A3="Months"
    A4=IF(ROW()-3>$B$2,"",DATE(YEAR($B$1),MONTH($B$1)+ROW()-4,1))

    Format A2 as "yyyy mmmm", or "yyyy mmm", or "yyyy.mm" ... , and copy down as
    much as you need.

    Arvi Laanemets


    "jsr" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I am looking for either a formula or code to execute the following:
    >
    > Start Month = X
    > Number of Months = Y
    >
    > and then autofill a row based on the following number of months from
    > the start month.
    >
    > any suggestions.
    >
    > Thanks
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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