Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referring a cell Terry0928 via OfficeKB.com Excel Discussion (Misc queries) 3 May 21st 10 09:22 AM
putting date in a cell referring to the tab sheet Rachel Excel Discussion (Misc queries) 1 November 6th 09 06:16 PM
Totalling by referring to 2 date ranges Mike Excel Discussion (Misc queries) 2 March 30th 05 01:59 AM
Totalling by referring to 2 date ranges Mike Excel Discussion (Misc queries) 0 March 29th 05 11:57 PM
referring to other worksheet Geetu M Excel Worksheet Functions 2 March 29th 05 09:37 PM


All times are GMT +1. The time now is 01:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"