powercell99
Board Regular
- Joined
- May 14, 2014
- Messages
- 75
I'm banging my head against my monitor here. Dealing with dates and VBA feels like ironing my tongue. What am i doing wrong in this code? I just want to do 2 things. If the cell in column 68 is blank, do nothing. If its not blank, check the date to see if its between the 1st and 15th of the current month. Any help or suggestions you could provide would really help me out.
HTML:
Sub datecheck()
Dim CurrenFirst As DateDim CurrentFifteenth As Date
Dim lastrow As LongDim rownum As LongDim NReq As DateDim newreqdt As Date
lastrow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).RowFor rownum = 2 To lastrowNReq = Sheets("Travel Table").Cells(rownum, 68)newreqdt = DateValue(NReq)
CurrenFirst = DateSerial(Year(Date), month(Date), 1)CurrenFifteenth = DateSerial(Year(Date), month(Date), 15)
If Cells(rownum, 68).Value <> "" And newreqdt >= CurrentFirst And newreqdt <= CurrentFifteenth Then Cells(rownum, 72).Value = Year(Date) & "-" & month(Date) End If Next rownum
End Sub