Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default 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
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
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Quick help with a simple function! [email protected] Excel Discussion (Misc queries) 4 July 20th 06 06:17 AM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
Excel should have a quick and simple "change case" function like . NinaSvendsen Excel Worksheet Functions 1 January 28th 05 03:15 PM
Quick VBA code question (if...then statement) abxy[_31_] Excel Programming 4 February 26th 04 01:04 AM


All times are GMT +1. The time now is 07:01 AM.

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"