gareth1979
New Member
- Joined
- May 28, 2018
- Messages
- 5
In simple term I want to create a simple vb script in excel that looks at the system date and then adds 1 to a cell on my sheet if it falls between a particular date range for example my dates 01/05/2018 to 31/05/2018 the system date is 28/05/2018 so adds 1 to my spreadsheet
I have tried playing around with numerous way but I am not getting anywhere
Public Sub test()
Dim d As Date
d = CDate(29 / 5 / 2019)
n = Now()
Range("a1").Value = d
If Year(d) = Year And Month(d) = Month Then
MsgBox "It works"
Else
MsgBox "It doesnt work"
End If
End Sub
Public Sub tryThis()
Dim xdate As Date
xdate = "4 / 27 / 2018"
Range("a1") = xdate
If Month(d) = Month(xdate) And Year(Date) = Year(xdate) Then
MsgBox "OK"
Else
MsgBox "not OK"
End If
End Sub
I have tried playing around with numerous way but I am not getting anywhere
Public Sub test()
Dim d As Date
d = CDate(29 / 5 / 2019)
n = Now()
Range("a1").Value = d
If Year(d) = Year And Month(d) = Month Then
MsgBox "It works"
Else
MsgBox "It doesnt work"
End If
End Sub
Public Sub tryThis()
Dim xdate As Date
xdate = "4 / 27 / 2018"
Range("a1") = xdate
If Month(d) = Month(xdate) And Year(Date) = Year(xdate) Then
MsgBox "OK"
Else
MsgBox "not OK"
End If
End Sub