View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
peter.thompson[_12_] peter.thompson[_12_] is offline
external usenet poster
 
Posts: 1
Default If/then code problem


I have a userform that contains a 'start month' text box and an 'en
month' text box for input.

The value in the start month textbox must be equal to or less than th
value in th end month text box.

I need to generate an error message if user accidentaly enters a valu
in the 'end month' tbox that is greater than the end month value

I have written the following code

If txtStartMonth.Value txtEndMonth.Value then

MsgBox "start month must be equal to or less than value of end month"

The problem:

Say end month value is 60

As soon as I enter a value in the start month text box greater than 6
the error message displays?

I must be doing something basically wrong. Any help appreciated

Peter (new to VBA, and learning the hard way!

--
peter.thompso
-----------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...fo&userid=2968
View this thread: http://www.excelforum.com/showthread.php?threadid=49609