excel - 我陷入了无限循环
问题描述
我正在使用 Vba 在 Excel 上编辑报告工具,我在另一个工作表中创建了一个新的数据透视表,并希望使用该数据透视表的结果来编辑另一个工作表。但我现在陷入了一个循环
Check the number of division for the LM
Divisions_Count.Select
CntRow = 2
Do While Divisions_Count.Cells(CntRow, 1).Value <> "Grand Total"
If Details.Cells(DetRow, 1).Value = Divisions_Count.Cells(CntRow, 1).Value Then
Nb_Div = Divisions_Count.Cells(CntRow, 2).Value
Else
CntRow = CntRow + 1
End If
Loop
解决方案
试试这个:
Do While Divisions_Count.Cells(CntRow, 1).Value <> "Grand Total"
If Details.Cells(DetRow, 1).Value = Divisions_Count.Cells(CntRow, 1).Value Then
Nb_Div = Divisions_Count.Cells(CntRow, 2).Value
End If
CntRow = CntRow + 1
Loop
(未经测试)