![]() |
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 |
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" wrote in message oups.com... 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 |
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" wrote in message oups.com... 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 |
All times are GMT +1. The time now is 12:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com