2012-09-12 69 views
2

我在Excel中的Excel:使用公式長於255個字符

=CONCATENATE("insert into #UpdateData (mondayopenhour, mondayopenmin,mondayclosehour, mondayclosemin,tuesdayopenhour, tuesdayopenmin,tuesdayclosehour, tuesdayclosemin,wednesdayopenhour, wednesdayopenmin, wednesdayclosehour, wednesdayclosemin,thursdayopenhour, thursdayopenmin,thursdayclosehour, thursdayclosemin, fridayopenhour, fridayopenmin, fridayclosehour, fridayclosemin, saturdayopenhour, saturdayopenmin, saturdayclosehour, saturdayclosemin, sundayopenhour, sundayopenmin, sundayclosehour, sundayclosemin values ('",TRIM(A2),"',",MID(B2,1,2),",",MID(B2,3,2),",",MID(C2,1,2),",",MID(C2,3,2),",",MID(D2,1,2),",",MID(D2,3,2),",",(MID(E2,1,2),",",MID(E2,3,2),",",MID(F2,1,2),",",MID(F2,3,2),",",MID(G2,1,2),",",MID(G2,3,2),",",MID(H2,1,2),",",MID(H2,3,2),",",MID(I2,1,2),",",MID(I2,3,2),",",MID(J2,1,2),",",MID(J2,3,2),",",MID(K2,1,2),",",MID(K2,3,2),",",MID(L2,1,2),",",MID(L2,3,2),",",MID(M2,1,2),",",MID(M2,3,2),",",MID(N2,1,2),",",MID(N2,3,2),",",MID(O2,1,2),",",MID(O2,3,2),")") 

下面的公式,當我嘗試運行它,我得到的公式以下錯誤

文本值被限定在255個字符。要在公式中創建長度超過255個字符的文本 值,請使用CONCATENATE 函數或連接運算符(&)。

我一直在網上尋找這個,但沒有得到真正的解決方案!有誰知道如何解決這個問題?

回答

3

現在這是一個凌亂的功能。你必須分開你的輸入CONCATENATE

現在你在那裏只有一個非常大的字符串,以「insert ...」開頭,結尾是「.... MID(O2,3,2),」)「 - 或者至少,這就是我認爲這結束,因爲,所有的「」這是非常艱難的步驟通過這個

這裏是你應該如何使用CONCATENATE

=CONCATENATE("insert into #UpdateData (mondayopenhour,","mondayopenmin,") 

您可以擴展這一點,所以你不會有單個字符串長度超過255個字符

編輯:順便說一句 - 您當前的字符串大約有972個字符cters。

您可以通過使用這個公式緩解分拆:

=MID("insert into #UpdateData (mondayopenhour, mondayopenmin,mondayclosehour, mondayclosemin,tuesdayopenhour, tuesdayopenmin,tuesdayclosehour, tuesdayclosemin,wednesdayopenhour, wednesdayopenmin, wednesdayclosehour, wednesdayclosemin,thursdayopenhour, thursdayopenmin,thursdayclosehour, thursdayclosemin, fridayopenhour, fridayopenmin, fridayclosehour, fridayclosemin, saturdayopenhour, saturdayopenmin, saturdayclosehour, saturdayclosemin, sundayopenhour, sundayopenmin, sundayclosehour, sundayclosemin values ('",TRIM(A2),"',",MID(B2,1,2),",",MID(B2,3,2),",",MID(C2,1,2),",",MID(C2,3,2),",",MID(D2,1,2),",",MID(D2,3,2),",",(MID(E2,1,2),",",MID(E2,3,2),",",MID(F2,1,2),",",MID(F2,3,2),",",MID(G2,1,2),",",MID(G2,3,2),",",MID(H2,1,2),",",MID(H2,3,2),",",MID(I2,1,2),",",MID(I2,3,2),",",MID(J2,1,2),",",MID(J2,3,2),",",MID(K2,1,2),",",MID(K2,3,2),",",MID(L2,1,2),",",MID(L2,3,2),",",MID(M2,1,2),",",MID(M2,3,2),",",MID(N2,1,2),",",MID(N2,3,2),",",MID(O2,1,2),",",MID(O2,3,2),")",2,255) 
+0

林不知道如果'= PART'工作,但我設法打破文本塊,然後通過使用'= C2&C3細胞拼湊回來一起細胞來解決這個問題&C4&C5' –

+0

@HipHipArray yes - 您也可以使用'&',但不必將文本分隔爲單個單元格,也可以在字符串中使用'&'。但我相信,分離將有助於進一步審查。你也可以命名你的單元格(例如'MONDAYS'而不是'C2'),這可能會幫助你進一步瞭解'C2'的背後。 – Jook

+0

這個問題被問到很長時間了,但什麼是「= PART()」函數?我無法在任何地方找到它......? – Sancarn

3

解決這個問題最簡單的方法是使用一些單元格來構建單獨的字符串元素,並使用concetanate將它們合併到一個單元格中。 它爲解決錯誤提供了更多的空間 - 也許你的陳述有錯誤,但它們將會是無形的doe。

7

我正好碰到這個問題太...但它不是一個真正的問題。一個單元格中只能有255個字符,但在公式中無限制。你的公式會導致一個錯誤,所以Excel將它作爲文本而不是公式讀取。 找到你的錯誤,你的公式將起作用。

1

至於我對同一問題的解決方案,那些長文本我把它放在一個單獨的單元格上,而不是我的公式本身的一部分。 例子:

=CONCATENATE("INSERT INTO CAS_ACD (ACD_NUMBER, WAGON_WHEEL_INDEX, WAGON_WHEEL_COUNT, WAGON_WHEEL_COUNT_MAX, WAIT_TIME, MAX_WAIT_TIME, 
MON_TIME, TUE_TIME, WED_TIME, THU_TIME, FRI_TIME, SAT_TIME, SUN_TIME, DATE_CLOSED1, 
DATE_CLOSED2, DATE_CLOSED3, DATE_CLOSED4, DATE_CLOSED5, DATE_CLOSED6, DATE_CLOSED7, DATE_CLOSED8, 
DATE_CLOSED9, DATE_CLOSED10, DATE_CLOSED11, DATE_CLOSED12, DATE_CLOSED13, DATE_CLOSED14, 
DATE_CLOSED15, DATE_CLOSED16, DATE_CLOSED17, DATE_CLOSED18, DATE_CLOSED19, DATE_CLOSED20, 
CTI_SERVER_ADDR, PROGRAM_NUM, VERSION_NUM, COMMENTS, TOD_VOICE_DIR, TOD_VS, ACD_NAME) 
VALUES ("B2, C2,");") 

相反,我這個存儲單元格A2的一個

Cell A2 now contains= 
INSERT INTO CAS_ACD (ACD_NUMBER, WAGON_WHEEL_INDEX, WAGON_WHEEL_COUNT, WAGON_WHEEL_COUNT_MAX, WAIT_TIME, MAX_WAIT_TIME, 
MON_TIME, TUE_TIME, WED_TIME, THU_TIME, FRI_TIME, SAT_TIME, SUN_TIME, DATE_CLOSED1, 
DATE_CLOSED2, DATE_CLOSED3, DATE_CLOSED4, DATE_CLOSED5, DATE_CLOSED6, DATE_CLOSED7, DATE_CLOSED8, 
DATE_CLOSED9, DATE_CLOSED10, DATE_CLOSED11, DATE_CLOSED12, DATE_CLOSED13, DATE_CLOSED14, 
DATE_CLOSED15, DATE_CLOSED16, DATE_CLOSED17, DATE_CLOSED18, DATE_CLOSED19, DATE_CLOSED20, 
CTI_SERVER_ADDR, PROGRAM_NUM, VERSION_NUM, COMMENTS, TOD_VOICE_DIR, TOD_VS, ACD_NAME) 
VALUES (' 

所以我的公式是現在

=CONCATENATE(A2, B2, C2) 
0

我有這個問題, 「超過255個字符」並輕鬆解決它沒有CONCATENATE:

我把單元格T1值長的字符串。 然後我的公式如下:

="INSERT INTO sql_table_name ("&T1&") VALUES ('"&A40&"','"&B40&"','"&C40&"','"&D40&"','"&E40&"','"&F40&"','"&G40&"','"&H40&"','"&I40&"','"&J40&"','"&K40&"','"&L40&"','"&M40&"','"&N40&"','"&O40&"','"&P40&"','"&Q40&"','"&R40&"','"&S40&"');" 
相關問題