ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming to put in dates (https://www.excelbanter.com/excel-programming/273100-programming-put-dates.html)

Haas

Programming to put in dates
 
Hi all! I was wondering if you can help me with a problem I'm having -
I'm a beginner so any help would be truly appreciated.

What code can I write to solve this problem?:

In cell B1, I have an inception year for a contract (i.e., 1985); in
the cell right below it, namely B2, I have the ending date (2003).
Now, starting from cell A5, I want to automatically have the years
going from 1985 to 2003 (or whatever the beginning year is and the
ending year.) I know I can have a calculation put into the cells, but
would rather run a macro because I will need to enter more info later.

Can anyone help? please?

Example

Beginning Year 1985
Ending YEar 2005



1985
1986
1987
1988
1989
etc..

Thanks!

Haas

MacroMan

Programming to put in dates
 
The following should work for you (only fix the line
breaks):

Do
x = x + 1
Range("A5").Offset(x - 1, 0).Value = _
Range("B1").Value + x - 1
Loop Until Range("A5").Offset(x - 1, 0).Value = _
Range("B2").Value

HTH

-----Original Message-----
Hi all! I was wondering if you can help me with a problem

I'm having -
I'm a beginner so any help would be truly appreciated.

What code can I write to solve this problem?:

In cell B1, I have an inception year for a contract

(i.e., 1985); in
the cell right below it, namely B2, I have the ending

date (2003).
Now, starting from cell A5, I want to automatically have

the years
going from 1985 to 2003 (or whatever the beginning year

is and the
ending year.) I know I can have a calculation put into

the cells, but
would rather run a macro because I will need to enter

more info later.

Can anyone help? please?

Example

Beginning Year 1985
Ending YEar 2005



1985
1986
1987
1988
1989
etc..

Thanks!

Haas
.


Tom Ogilvy

Programming to put in dates
 
Sub fill2()
For i = Range("B1").Value To Range("B2").Value
Range("A5").Offset(i - Range("B1").Value, 0).Value = i
Next i

End Sub

--
Regards,
Tom Ogilvy



Haas wrote in message
om...
Hi all! I was wondering if you can help me with a problem I'm having -
I'm a beginner so any help would be truly appreciated.

What code can I write to solve this problem?:

In cell B1, I have an inception year for a contract (i.e., 1985); in
the cell right below it, namely B2, I have the ending date (2003).
Now, starting from cell A5, I want to automatically have the years
going from 1985 to 2003 (or whatever the beginning year is and the
ending year.) I know I can have a calculation put into the cells, but
would rather run a macro because I will need to enter more info later.

Can anyone help? please?

Example

Beginning Year 1985
Ending YEar 2005



1985
1986
1987
1988
1989
etc..

Thanks!

Haas




Haas[_2_]

Programming to put in dates
 
Thank you for all your help...both answers provided alternative means for a
solution for the same problem.

This group is great!

Haas

"Tom Ogilvy" wrote in message
...
Sub fill2()
For i = Range("B1").Value To Range("B2").Value
Range("A5").Offset(i - Range("B1").Value, 0).Value = i
Next i

End Sub

--
Regards,
Tom Ogilvy



Haas wrote in message
om...
Hi all! I was wondering if you can help me with a problem I'm having -
I'm a beginner so any help would be truly appreciated.

What code can I write to solve this problem?:

In cell B1, I have an inception year for a contract (i.e., 1985); in
the cell right below it, namely B2, I have the ending date (2003).
Now, starting from cell A5, I want to automatically have the years
going from 1985 to 2003 (or whatever the beginning year is and the
ending year.) I know I can have a calculation put into the cells, but
would rather run a macro because I will need to enter more info later.

Can anyone help? please?

Example

Beginning Year 1985
Ending YEar 2005



1985
1986
1987
1988
1989
etc..

Thanks!

Haas







All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com