Vba 如果单元格中包含“Excel”-&引用;靠近数字然后移动
我需要做的是基本上写课程号。共有3列。 第二列由一个名为LessonsLeft的自定义公式运行,该公式是由我在stackoverflow上的第二个线程中的某个人完成的Vba 如果单元格中包含“Excel”-&引用;靠近数字然后移动,vba,excel,Vba,Excel,我需要做的是基本上写课程号。共有3列。 第二列由一个名为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, ",") Lessons
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 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
函数lessonsAtTestedButNotDone(rng作为范围)作为字符串
如果rng.Count>1,则退出函数
Dim spltStr()作为字符串,lessonDone作为字符串
我想我会坚持多久
spltStr=拆分(rng.Value,“,”)
对于i=LBound(spltStr)至UBound(spltStr)
lessonDone=spltStr(一)
如果正确(第二课,1)=“-”,那么
lessonDone=左(lessonDone,Len(lessonDone)-1)
lessonsattendbutnotdone=lessonsattendbutnotdone&lessonDone&“
如果结束
下一个
如果LessonSattedButNotDone“”则LessonSattedButNotDone=左(LessonSattedButNotDone,Len(LessonSattedButNotDone)-1)
端函数
使用此功能
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
函数lessonsAtTestedButNotDone(rng作为范围)作为字符串
如果rng.Count>1,则退出函数
Dim spltStr()作为字符串,lessonDone作为字符串
我想我会坚持多久
spltStr=拆分(rng.Value,“,”)
对于i=LBound(spltStr)至UBound(spltStr)
lessonDone=spltStr(一)
如果正确(第二课,1)=“-”,那么
lessonDone=左(lessonDone,Len(lessonDone)-1)
lessonsattendbutnotdone=lessonsattendbutnotdone&lessonDone&“
如果结束
下一个
如果LessonSattedButNotDone“”则LessonSattedButNotDone=左(LessonSattedButNotDone,Len(LessonSattedButNotDone)-1)
端函数
我的意思是,例如,如果我在第一列“5-”,5将出现在第三列。我的意思是,如果我在第一列“5-”,5将出现在第三列。这是在做这项工作。谢谢,这就是工作。谢谢