爲此,我們需要將,
上的字符串拆分,然後將其替換爲無。
這UDF你想要做什麼:
Function LessonsLeft(rng As Range) As String
If rng.Count > 1 Then Exit Function
Dim spltStr() As String
Dim i As Long
spltStr = Split(rng.Value, ",")
LessonsLeft = ",1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,"
For i = LBound(spltStr) To UBound(spltStr)
LessonsLeft = Replace(LessonsLeft, "," & spltStr(i) & ",", ",")
Next i
LessonsLeft = Mid(LessonsLeft, 2, Len(LessonsLeft) - 2)
End Function
把它連接到工作簿中的模塊中,那麼你會用一個公式把它叫做:
=LessonsLeft(A1)
因此,一個細胞將爲前。 1,2,3,4,5,6等一個會自動被7,8,9,10,12 ...最多50. –
Excel 2016,最新的一個 –