M
mariasa
Hi,
Could you please help me make this code more flexible?
Basically right now it performs the procedure only for the sheet name
943. But i have 66 sheets that i want it to take care of and they ar
listed on sheet 1 of my workbook (they are not consecutive number
however, so the macro has to go to sheet1 and loop through an array o
sheet numbers/names and perform the below functions on them. Hope thi
doesnt sound too confusing.
Thanks so much.
Regards,
Maria
Sub CommandButtonDRG_Click()
Dim i As Integer
Dim curCell As Date
Dim startDate As Date
Dim endDate As Date
Dim SheetNumber As String
SheetNumber = "943"
startDate = Sheets(SheetNumber).Range("c2").Value
endDate = Sheets(SheetNumber).Range("e2").Value
Sheets(SheetNumber).Columns("C:C").Select
Selection.NumberFormat = "m/d/yyyy"
Sheets(SheetNumber).Range("c2").Select
ActiveCell.FormulaR1C1 = startDate
i = 3
Do
curCell = Sheets(SheetNumber).Cells(i, 3).Select
ActiveCell.FormulaR1C1 = "=dvstradedate(R[-1]C,1)"
i = i + 1
Loop Until Sheets(SheetNumber).Cells(i - 1, 3).Value = endDate
End
End Su
Could you please help me make this code more flexible?
Basically right now it performs the procedure only for the sheet name
943. But i have 66 sheets that i want it to take care of and they ar
listed on sheet 1 of my workbook (they are not consecutive number
however, so the macro has to go to sheet1 and loop through an array o
sheet numbers/names and perform the below functions on them. Hope thi
doesnt sound too confusing.
Thanks so much.
Regards,
Maria
Sub CommandButtonDRG_Click()
Dim i As Integer
Dim curCell As Date
Dim startDate As Date
Dim endDate As Date
Dim SheetNumber As String
SheetNumber = "943"
startDate = Sheets(SheetNumber).Range("c2").Value
endDate = Sheets(SheetNumber).Range("e2").Value
Sheets(SheetNumber).Columns("C:C").Select
Selection.NumberFormat = "m/d/yyyy"
Sheets(SheetNumber).Range("c2").Select
ActiveCell.FormulaR1C1 = startDate
i = 3
Do
curCell = Sheets(SheetNumber).Cells(i, 3).Select
ActiveCell.FormulaR1C1 = "=dvstradedate(R[-1]C,1)"
i = i + 1
Loop Until Sheets(SheetNumber).Cells(i - 1, 3).Value = endDate
End
End Su