【测试管理】根据用例表新增统计数

直接上代码


Private Sub casecount_Click()
    Dim str As String
    Dim hang As Integer
    Dim hang1 As Integer
    Dim hang2 As Integer
    Dim cellname As String
   
    Dim hangcell As Integer
    Dim hangcell1 As Integer
    Dim liebei As String
    
    Dim maoyan As Integer
    Dim guanjian As Integer
    Dim jianyi As Integer
    Dim countmaoyan As Integer
    Dim countmaoyan1 As Integer
    Dim countguanjian As Integer
    Dim countguanjian1 As Integer
    Dim countjianyi As Integer
    Dim countjianyi1 As Integer
    
    '从D5开始判断是否有三级模块名
    If Range("D5") = "" Or Range("D5") = " " Then
        
        str = "模块名为空!!!" & vbCrLf & "请检查该模块用例是否被删除或修改"
        MsgBox (str)
        
        '如果有,开始从D5到碰到 单元格A含有总计 结束,取单元格D所有模块名
        Else
            For hang = 5 To 200
                hang1 = hang
                If Cells(hang, 1).Value <> "总计" Then
                    cellname = Cells(hang1, 4)
                    
                    '跳转到具体模块的详情
                    Sheets(cellname).Select
                    maoyan = 0
                    guanjian = 0
                    jianyi = 0
                    
                    '统计模块上的冒烟、关键、建议所有用例数
                    For hangcell = 3 To 2000
                        hangcell1 = hangcell
                        
                         liebei = ActiveSheet.Cells(hangcell, 2).Value
                         Select Case liebei
                         Case "冒烟":
                            maoyan = maoyan + 1
                         Case "关键":
                            guanjian = guanjian + 1
                         Case "建议":
                            jianyi = jianyi + 1
                         Case "":
                            Exit For
                         Case " ":
                            Exit For
                         End Select
                      Next
                    
                    
                     Cells(hang, 5).Value = maoyan
                     Cells(hang, 6).Value = guanjian
                     Cells(hang, 7).Value = jianyi
                    
                    '返回目录
                     Sheets("测试方案目录").Select
                     
                     '如果等于总计,推出循环
                     Else
                         Exit For
                 End If
                Next
                
                '将获取到的所有模块的冒烟总数、关键总数、建议总数全部累加算入总数
                countmaoyan = 0
                countguanjian = 0
                countjianyi = 0
                For hang = 5 To 200
                    
                    If Cells(hang, 1).Value <> "总计" Then
                       countmaoyan1 = 0
                       countmaoyan1 = Cells(hang, 5).Value
                       countmaoyan = countmaoyan + countmaoyan1
                       
                       countguanjian1 = 0
                       countguanjian1 = Cells(hang, 6).Value
                       countguanjian = countguanjian + countguanjian1
                       
                       countjianyi1 = 0
                       countjianyi1 = Cells(hang, 7).Value
                       countjianyi = countjianyi1 + countjianyi
                       
                    Else
                        Cells(hang, 5).Value = countmaoyan
                        Cells(hang, 6).Value = countguanjian
                        Cells(hang, 7).Value = countjianyi
                        Exit For
                    End If
                Next
                
            
            
        End If
End Sub

 

效果图

 

 

 

 

 

posted @ 2020-09-28 10:54  Xiao世  阅读(88)  评论(0编辑  收藏  举报