ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¦p¦ó§Q¥ÎVBA¥hÅçÃÒ ªí³æ¤W­±ªºÄæ¦ìÄÝ©Ê

¦p¦ó§Q¥ÎVBA¥hÅçÃÒ ªí³æ¤W­±ªºÄæ¦ìÄÝ©Ê

·Q½Ð°Ý¤@¤U¤j¤j
¦pªG·Q­nÅçÃÒ¿é¤JªºÄæ¦ì¡G
     1. ¿é¤J¤º®e¥²¶·¬°¤é´Á¡C
     2. «ü©w¿é¤Jªº®É¶¡¥²¶·¬°2013/1/1 ~ 2013/12/31¡C
     3. ¦pªG¿é¤J8/8¡A·|¦Û°Ê§ó·s¬°2013/8/8¡C

§Ú¥Î¿ý»s¾Þ§@ªºµ{¦¡½X
  1. Sub Macro14()
  2. '
  3. ' Macro14 Macro
  4. '
  5. '
  6.     With Selection.Validation
  7.         .Delete
  8.         .Add Type:=xlValidateDate, AlertStyle:=xlValidAlertStop, Operator:= _
  9.         xlBetween, Formula1:="1/31/2013", Formula2:="12/31/2013"
  10.         .IgnoreBlank = True
  11.         .InCellDropdown = True
  12.         .InputTitle = ""
  13.         .ErrorTitle = "½Ð¿é¤J¥¿½Tªº®æ¦¡"
  14.         .InputMessage = ""
  15.         .ErrorMessage = _
  16.        "1.±z¿é¤Jªº¤£¬O¤é´Á¡C" & Chr(10) & "2.±zªº¤é´Á®æ¦¡¿ù»~¡A¥¿½T³W®æ¬°YYYY/MM/DD¡C" &Chr(10) & "3.±z¿é¤Jªº¤é´Á¥¼¤¶©ó2013/1/1~2013/12/31¤§¶¡¡C" &Chr(10) &""
  17.         .IMEMode = xlIMEModeOff
  18.         .ShowInput = True
  19.         .ShowError = True
  20.     End With
  21. End Sub
½Æ»s¥N½X
¦ý¬O­n«ç»ò­×§ï©ñ¦bªí³æ¸Ì­±©O?
§Æ±æ¤j¤j«ü¾É¤@¤U ><
Jared

¦^´_ 1# Jared
  1. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
  2.   Const START_DATE = "2013/1/1"
  3.   Const END_DATE = "2013/12/31"
  4.   
  5.   If TextBox1 = vbNullString Then Exit Sub  '¥¼¶ñ©¿²¤
  6.      
  7.   If IsDate(TextBox1) Then
  8.     If CDate(TextBox1) > DateValue(START_DATE) And CDate(TextBox1) < DateValue(END_DATE) Then
  9.         TextBox1 = Format(TextBox1, "yyyy/m/d")
  10.     Else
  11.       MsgBox "±z¿é¤Jªº¤é´Á¥¼¤¶©ó" & START_DATE & "~" & END_DATE & "¤§¶¡¡C"
  12.       Cancel = True
  13.     End If
  14.   Else
  15.     MsgBox "±zªº¤é´Á®æ¦¡¿ù»~¡A¥¿½T³W®æ¬°YYYY/MM/DD¡C"
  16.     Cancel = True
  17.   End If
  18. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# stillfish00


    ·PÁ¤j¤jªº¨ó§U ^^
    ·Q½Ð°Ý¤@¤U¤j¤j
    ÅçÃÒ¤é´Á ¥²¶·¥]ÂЦb Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    ³o­Óµ{¦¡½XªºÄݩʤU­±¶Ü? (@@)
Jared

TOP

¦^´_ 3# Jared
TextBox1 : ªí³æ¤W¥Î¨Ó¿é¤J¤é´Áªº¤å¦r¤è¶ô
TextBox1_Exit : ¸Ó¤å¦r¤è¶ôªºExit¨Æ¥ó¡Aªí¥Ü·í¨Ï¥ÎªÌ¥´§¹¤é´Á«á«ötab©ÎenterÂ÷¶}¸Ó¤å¦r¤è¶ô®É·|¦Û¤vIJµo¡A°Ñ¼Æªºcancel¥i³]©w¨Ï¨ä¤£¥¢¥h¾nÂI(¤å¦r´å¼Ð¯d¦b¸Ó¤å¦r¤è¶ô)¡C

«e­±ªºCode­n©ñ¦b¸Óªí³æªºµ{¦¡½X­¶­±¡C

TOP

¦^´_ 4# stillfish00


    ^^ ÁÂÁ¤j¤jªº¸Ñµª
    §Úª¾¹D¤F
Jared

TOP

        ÀR«ä¦Û¦b : ¦n¨Æ­n´£±o°_¡A¬O«D­n©ñ±o¤U¡A¦¨´N§O¤H§Y¬O¦¨´N¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD