View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
alexandraVBAgirl alexandraVBAgirl is offline
external usenet poster
 
Posts: 12
Default Reposting Date List Generation Question

Okay I guess my question sounded confusing before so I revised it.
Below is the code thats supposed to take the start date and the end date and
list all the trading days in between and including the start and end dates.
The macro is taking the trading days data from DVS Reporter through a simple
formula =DVStradingDay(the start date, 1 (means next one, if u put 0, it'll
show the start date again). Anyhow, so my code fails to stop at the end date.
Can you help me with that please?


Sub click()

Dim counter As Integer
Dim curCell As Date
Dim startDate As Date
Dim endDate As Date

startDate = Range("e1").Value
endDate = Range("e2").Value

Columns("C:C").Select
Selection.NumberFormat = "m/d/yyyy"
Range("C1").Select
ActiveCell.FormulaR1C1 = startDate

For counter = 2 To 20
curCell = Worksheets("sheet1").Cells(counter, 3).Select
ActiveCell.FormulaR1C1 = "=dvshandelsdatum(R[-1]C,1)"
If curCell endDate Then curCell = ""
Next counter

End Sub

Also i have hear for counter =2 to 20, but ideally there should be like
infinity or the entire column instead of 20, the macro should be executed
till the cell shows the end date. Any suggestions?

Here is the output with this code

1/1/2005 start date 1/1/2005
1/3/2005 end date 1/5/2005
1/4/2005
1/5/2005
1/6/2005
1/7/2005
1/10/2005
1/11/2005
1/12/2005
1/13/2005
1/14/2005
1/17/2005
1/18/2005
1/19/2005
1/20/2005
1/21/2005
1/24/2005
1/25/2005
1/26/2005
1/27/2005


Thanks.