Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
You are doing a string comparison by the looks of it. Try If cint(txtStartMonth.Text) cint(txtEndMonth.Text) Robin Hammond www.enhanceddatasystems.com "peter.thompson" <peter.thompson.20odwy_1135647901.9001@excelforu m-nospam.com wrote in message news:peter.thompson.20odwy_1135647901.9001@excelfo rum-nospam.com... I have a userform that contains a 'start month' text box and an 'end month' text box for input. The value in the start month textbox must be equal to or less than the value in th end month text box. I need to generate an error message if user accidentaly enters a value 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.thompson ------------------------------------------------------------------------ peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686 View this thread: http://www.excelforum.com/showthread...hreadid=496092 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks Robin..fixed it right up! Cheers, Peter (new to VBA...slowly getting it! -- 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code Problem | Excel Programming | |||
Problem with the end of this code | Excel Programming | |||
Code Problem | Excel Programming | |||
VBA code problem | Excel Programming | |||
Problem with this code | Excel Programming |