VBA for generating dates how to apply the sub from one cell to one column?

evalam

New Member
Joined
Jul 15, 2014
Messages
7
hey everyone the following sub generates dates in cells a2,b2 and returns the result in c2
i need to apply the sub in to colummn A and column B any ideas ?

my data have the form below and i have almost 10.000
A B
[TABLE="width: 165"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]startdate[/TD]
[TD]enddate[/TD]
[/TR]
[TR]
[TD="align: right"]2013-09-08[/TD]
[TD="align: right"]2013-11-08[/TD]
[/TR]
[TR]
[TD="align: right"]2013-09-22[/TD]
[TD="align: right"]2013-11-03[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 265"]
<colgroup><col span="3"><col></colgroup><tbody>[TR]
[TD="colspan: 2"]




Sub flight()[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]Dim FirstDate As Date[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]Dim LastDate As Date[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]Dim NextDate As Date[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Dim r As Long[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]FirstDate = Range("A2").Value[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]LastDate = Range("B2").Value[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]NextDate = FirstDate[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Range("c2").Select[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 4"]'selection of columns within one row[/TD]
[/TR]
[TR]
[TD="colspan: 3"]Do Until NextDate > LastDate[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"] ActiveCell.Value = NextDate[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 4"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="colspan: 3"] NextDate = NextDate + 7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Loop[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top