Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jsr jsr is offline
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FORMULA TO INCREMENT 25 MONTHS BASED ON A DATE CELL SorianoP Excel Discussion (Misc queries) 4 August 14th 06 11:46 PM
Start Date minus (Years + Months + Days) = ? quartz[_2_] Excel Programming 3 May 11th 06 06:05 PM
Code for auto filling in Excel based on number of months, & start date Diane Sulton Excel Programming 1 March 1st 06 01:15 AM
AutoFill Visible Cells with Months Elaine New Users to Excel 3 March 16th 05 10:13 PM
Formula to calucate # of months based on a speificed date entered David Excel Worksheet Functions 4 December 15th 04 06:57 PM


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"