如果单元格包含“ – ”数字,则移动Excel

我需要做的是基本写作课程编号。 有3个colomns。 在这里输入图像说明

第二列是由一个名为LessonsLeft的自定义公式运行的,这个自定义公式是由我的第二个线程在stackoverflow上完成的

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 

我需要做的是增加另一个第三个课程,这个课程是我的学生第一次尝试的课程,但是他们不能通过考试。

我希望数据如何存在,就是在第一列的数字附近写一个“ – ”或“+”,这样数字就会移到第三列。

如何做呢 ?

使用这个function

 Function LessonsAttemptedButNotDone(rng As Range) As String If rng.Count > 1 Then Exit Function Dim spltStr() As String, lessonDone As String Dim i As Long spltStr = Split(rng.Value, ",") For i = LBound(spltStr) To UBound(spltStr) lessonDone = spltStr(i) If Right(lessonDone, 1) = "-" Then lessonDone = Left(lessonDone, Len(lessonDone) - 1) LessonsAttemptedButNotDone = LessonsAttemptedButNotDone & lessonDone & "," End If Next If LessonsAttemptedButNotDone <> "" Then LessonsAttemptedButNotDone = Left(LessonsAttemptedButNotDone, Len(LessonsAttemptedButNotDone) - 1) End Function