Board logo

標題: [發問] 因為函數超過字元數,能否改寫到程式區? [打印本頁]

作者: av8d    時間: 2017-3-14 11:06     標題: 因為函數超過字元數,能否改寫到程式區?

從C2開始,
每當C2改變時,G2帶入一大串函數。
每當C3改變時,G3帶入一大串函數。
............................................................................
............................................................................
............................................................................
............................................................................
每當C100改變時,G100帶入一大串函數。

由於函數字元數過多,他會顯示無法,不知道是可以在程式區使用
函數我先暫時列出一小段
=IF(AND(DATEDIF(C2,H2,"y")=0,DATEDIF(C2,H2,"ym")<6),
IF(AND(DATEDIF(H2,I2,"ym")=0,DATEDIF(H2,I2,"md")<>0),"再"&DATEDIF(H2,I2,"md")&"天,滿6個月,特休3天。",
IF(AND(DATEDIF(H2,I2,"ym")<>0,DATEDIF(H2,I2,"md")=0),"再"&DATEDIF(H2,I2,"ym")&"個月,滿6個月,特休3天。",
IF(AND(DATEDIF(H2,I2,"ym")<>0,DATEDIF(H2,I2,"md")<>0),"再"&DATEDIF(H2,I2,"ym")&"個月又"&DATEDIF(H2,I2,"md")&"天,滿6個月,特休3天。"))),
作者: av8d    時間: 2017-3-14 11:52

回復 1# av8d


    目前已知
  1. Private Sub Worksheet_Change(ByVal Target As Range)

  2.     With Target
  3.         i = 2
  4.         For j = i To 100
  5.             If .Row = j And .Column = 3 Then
  6.                 If .Value <> "" Then
  7.                 .Offset(0, 4) = ""
  8.                 End If
  9.             End If
  10.         Next
  11.     End With
  12. End Sub
複製代碼
.Offset(0, 4) = ""  因為 ""要寫入函數
目前還在研究中,我先截取一個最短的函數如下:
IF(AND(DATEDIF(C2,H2,"y")=0,DATEDIF(C2,H2,"ym")<6),
IF(AND(DATEDIF(H2,I2,"ym")=0,DATEDIF(H2,I2,"md")<>0),"再"&DATEDIF(H2,I2,"md")&"天,滿6個月,特休3天。",
IF(AND(DATEDIF(H2,I2,"ym")<>0,DATEDIF(H2,I2,"md")=0),"再"&DATEDIF(H2,I2,"ym")&"個月,滿6個月,特休3天。",
IF(AND(DATEDIF(H2,I2,"ym")<>0,DATEDIF(H2,I2,"md")<>0),"再"&DATEDIF(H2,I2,"ym")&"個月又"&DATEDIF(H2,I2,"md")&"天,滿6個月,特休3天。"))),




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)