Hi,
I have a macro like the following. I need to create a bunch of dates like "nov-5-2014" to "nov-19-2014" with weekly interval. But the date presented will be like '11/5/14', '11/19/14'. But the following code will not make '2014' to '14'. Besides, I don't want an apostrophe in front of the date to make it character.
The format I set up is 'm/d/yy' but still give me '2014'. Why???
Any suggestions are welcome.
Thanks in advance.
Public calyear As Integer
Public cycyear As Integer
Public mm As Byte
Public dd As Byte
Public ic As Byte
'mm=7, dd=4, calyear=2014 and so on
Sub DefPubVars()
mm = Sheets("ParmTab").Cells(1, 1)
dd = Sheets("ParmTab").Cells(2, 1)
calyear = Sheets("ParmTab").Cells(3, 1)
cycyear = Sheets("ParmTab").Cells(4, 1)
End Sub
Sub ChngWeekBKWD(HWWks As Integer)
Dim str_ddmmmyy As Variant
Dim i, j As Long
Call DefPubVars
str_ddmmmyy = mm & "-" & dd & "-" & calyear
rw = ActiveCell.Row
col = ActiveCell.Column
For i = 0 To (HWWks - 1) * 7 Step 7
j = HWWks + col - 1 - i / 7
ActiveSheet.Cells(rw, j) = "'" & Format(CDate(str_ddmmmyy) - i, "m/d/yy")
Next
End Sub
Sub Week8()
Dim q As Long
wk8 = Array("v", "ba")
For q = LBound(wk8) To UBound(wk8)
Cells(2, wk8(q)).Activate
ChngWeekBKWD 8
Next q
End Sub
the output goes like this:
5/16/2014, 5/23/2014, 5/30/2014, 6/6/2014, 6/13/2014, 6/20/2014, 6/27/2014, 7/4/2014
But again, I want something like 5/16/14, not 5/16/2014.
I have a macro like the following. I need to create a bunch of dates like "nov-5-2014" to "nov-19-2014" with weekly interval. But the date presented will be like '11/5/14', '11/19/14'. But the following code will not make '2014' to '14'. Besides, I don't want an apostrophe in front of the date to make it character.
The format I set up is 'm/d/yy' but still give me '2014'. Why???
Any suggestions are welcome.
Thanks in advance.
Public calyear As Integer
Public cycyear As Integer
Public mm As Byte
Public dd As Byte
Public ic As Byte
'mm=7, dd=4, calyear=2014 and so on
Sub DefPubVars()
mm = Sheets("ParmTab").Cells(1, 1)
dd = Sheets("ParmTab").Cells(2, 1)
calyear = Sheets("ParmTab").Cells(3, 1)
cycyear = Sheets("ParmTab").Cells(4, 1)
End Sub
Sub ChngWeekBKWD(HWWks As Integer)
Dim str_ddmmmyy As Variant
Dim i, j As Long
Call DefPubVars
str_ddmmmyy = mm & "-" & dd & "-" & calyear
rw = ActiveCell.Row
col = ActiveCell.Column
For i = 0 To (HWWks - 1) * 7 Step 7
j = HWWks + col - 1 - i / 7
ActiveSheet.Cells(rw, j) = "'" & Format(CDate(str_ddmmmyy) - i, "m/d/yy")
Next
End Sub
Sub Week8()
Dim q As Long
wk8 = Array("v", "ba")
For q = LBound(wk8) To UBound(wk8)
Cells(2, wk8(q)).Activate
ChngWeekBKWD 8
Next q
End Sub
the output goes like this:
5/16/2014, 5/23/2014, 5/30/2014, 6/6/2014, 6/13/2014, 6/20/2014, 6/27/2014, 7/4/2014
But again, I want something like 5/16/14, not 5/16/2014.