在这个循环中实现语音合成

我有以下代码:

Case "END-BOX" EndBox = ActiveCell.Row Selection.Offset(-1, 2).Select Selection.ClearContents Rows(2).Insert Shift:=xlDown TotalCols = ActiveSheet.UsedRange.Columns.Count Col = 4 Cells(EndBox, Col).Select For i = EndBox To 1 Step -1 If Cells(i, Col).Value <> "" Then n = n + 1 Else Cells(i, Col).Value = n If Cells(i, Col).Offset(0, -2).Value = "NEW-BOX" Then Cells(i, Col).Interior.ColorIndex = 4 n = 0 ' Application.Speech.Speak (n) End If Next Range(EndBox).Select Selection.Offset(1, -2).Select 

我想计算出总和计算后如何获得最终的总和数字,但是这个循环certificate了我的麻烦,我不明白我将如何实现这一点。 任何帮助将不胜感激。

n = 0

'Application.Speech.Speak(n)

你将n设置为0,所以你总会得到0。

把它放在Next之后,得到n的最终值

 For i = EndBox To 1 Step -1 If Cells(i, Col).Value <> "" Then n = n + 1 Else Cells(i, Col).Value = n If Cells(i, Col).Offset(0, -2).Value = "NEW-BOX" Then Cells(i, Col).Interior.ColorIndex = 4 n = 0 End If Next Application.Speech.Speak (n)