Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
in VB, how do i write:
if Combobox1 = "January" and today's date(system date) isn't equal t 2/2/04 or later then checkbox1.enabled = false thanks! : -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
abxy,
You're practically there with your English: If (ComboBox1.Text="January") AND (Now()<#2/2/04) Then CheckBox1.Enabled = False End If The backets are not required, but it makes the logic clearer. Also, I don't think you really want to hard code a date, especially one that is already in the past. NickHK "abxy " wrote in message ... in VB, how do i write: if Combobox1 = "January" and today's date(system date) isn't equal to 2/2/04 or later then checkbox1.enabled = false thanks! : ) --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
if combobox1.Text = "January" and date < DateValue("2/2/2004") Then
checkbox1.Enabled = False End if -- Regards, Tom Ogilvy "abxy " wrote in message ... in VB, how do i write: if Combobox1 = "January" and today's date(system date) isn't equal to 2/2/04 or later then checkbox1.enabled = false thanks! : ) --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
Hi
If ComboBox1.Value = "January" then If Date<2/2/04 then CheckBox1.enabled = False end if end if should work. This assumes that you are using the US date syntax of mm/dd/yy. If that is a problem, you might be better off using the DateSerial or DateValue functions. For example, using the date 3/2/04 to mean 2nd Mar 2004 (US syntax) you can make it less ambiguous for non US users by writing DateSerial(04,3,2) , or by using an unambiguous date format by writing DateValue("Mar 2, 2004") So that your first If statement is now If Date<DateSerial(04,3,2) then regards Paul abxy wrote in message ... in VB, how do i write: if Combobox1 = "January" and today's date(system date) isn't equal to 2/2/04 or later then checkbox1.enabled = false thanks! : ) --- Message posted from http://www.ExcelForum.com/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
Thanks everyone, you all were a big help...Actually last night,
wasn't getting any response so i just decided to fool around and I cam up with a solution but it wasn't working properly(working in som cases, but then not in others); it was this: If cboMonth.Value = "Febuary" And Date "2/06/04" Then chkWk1.Enabled = True End If then I saw you all's repsonses this morning and so i altered it t this: If cboMonth.Value = "Febuary" And Date DateValue("2/06/04") Then chkWk1.Enabled = True End If and it works perfect now...i guess the statement DateValue was neede to fine tune things Thank you veeeeeerry much everyone, i really appreciate you all's help -- Message posted from http://www.ExcelForum.com |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
? 2/2/04
0.25 Sure that is the test you intended? -- Regards, Tom Ogilvy "Paul Robinson" wrote in message om... Hi If ComboBox1.Value = "January" then If Date<2/2/04 then CheckBox1.enabled = False end if end if should work. This assumes that you are using the US date syntax of mm/dd/yy. If that is a problem, you might be better off using the DateSerial or DateValue functions. For example, using the date 3/2/04 to mean 2nd Mar 2004 (US syntax) you can make it less ambiguous for non US users by writing DateSerial(04,3,2) , or by using an unambiguous date format by writing DateValue("Mar 2, 2004") So that your first If statement is now If Date<DateSerial(04,3,2) then regards Paul abxy wrote in message ... in VB, how do i write: if Combobox1 = "January" and today's date(system date) isn't equal to 2/2/04 or later then checkbox1.enabled = false thanks! : ) --- Message posted from http://www.ExcelForum.com/ |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Another Quick Simple VBA question (if...then statement)
Goddamit!
Caught me out not testing before, and here I go doing it again... cheers Paul "Tom Ogilvy" wrote in message ... ? 2/2/04 0.25 Sure that is the test you intended? -- Regards, Tom Ogilvy "Paul Robinson" wrote in message om... Hi If ComboBox1.Value = "January" then If Date<2/2/04 then CheckBox1.enabled = False end if end if should work. This assumes that you are using the US date syntax of mm/dd/yy. If that is a problem, you might be better off using the DateSerial or DateValue functions. For example, using the date 3/2/04 to mean 2nd Mar 2004 (US syntax) you can make it less ambiguous for non US users by writing DateSerial(04,3,2) , or by using an unambiguous date format by writing DateValue("Mar 2, 2004") So that your first If statement is now If Date<DateSerial(04,3,2) then regards Paul abxy wrote in message ... in VB, how do i write: if Combobox1 = "January" and today's date(system date) isn't equal to 2/2/04 or later then checkbox1.enabled = false thanks! : ) --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF formula-simple question; simple operator | Excel Discussion (Misc queries) | |||
Quick help with a simple function! | Excel Discussion (Misc queries) | |||
Simple Simple Excel usage question | Excel Discussion (Misc queries) | |||
Excel should have a quick and simple "change case" function like . | Excel Worksheet Functions | |||
Quick VBA code question (if...then statement) | Excel Programming |