ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referring Date in VBA (https://www.excelbanter.com/excel-programming/308074-referring-date-vba.html)

anupam[_3_]

Referring Date in VBA
 
If c.Value <= #7/8/2004# Then
c.Value = #7/1/2004#
End If

but in this code i want to refer month as variable. i will accept th
month from user using inputbox.

how can i use variable for month in this code.

??????

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Referring Date in VBA
 
Dim res as String, lMon as Long
Dim dt as Date, dt1 as Date
res = InputBox("Enter Month as a number from 1 to 12)
if res = "" then exit sub
if isnumeric(res) then
lMon = clng(res)
if lMon = 1 and lMon <= 12 then
set dt = DateSerial(2004,lMon,8)
set dt1= DateSerial(2004,lMon,1)
if c.Value <= dt then
c.Value = dt1
End if
end if
Else
msgbox "Invalid entry"
End if

--
Regards,
Tom Ogilvy

"anupam " wrote in message
...
If c.Value <= #7/8/2004# Then
c.Value = #7/1/2004#
End If

but in this code i want to refer month as variable. i will accept the
month from user using inputbox.

how can i use variable for month in this code.

???????


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 12:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com