Dim App As New MSExcel.Application
Dim wb As MSExcel.WorkBook = App.WorkBooks.open(f1)
For Each Ws As MSExcel.WorkSheet In Wb.WorkSheets '
If ws.name = "分户快报" Then
For n1 As Integer = 3 To 5
For n2 As Integer = 4 To 48
If ws.cells(n2+1,n1+1).Formula = "" Then
ws.cells(n2+1,n1+1).Value = val(Sheet1(n2,n1).Value)
End If
Next
Next
End If
If ws.name = "资产负债表" Then
ws.cells(4,1).Value = Sheet2(3,0).Value '单位名称
ws.cells(2,1).Value = Sheet2(1,0).Value '日期
For n1 As Integer = 2 To 3
For n2 As Integer = 5 To 54
If ws.cells(n2+1,n1+1).Formula = "" Then
ws.cells(n2+1,n1+1).Value = val(Sheet2(n2,n1).Value)
End If
If ws.cells(n2+1,n1+5).Formula = "" Then
ws.cells(n2+1,n1+5).Value = val(Sheet2(n2,n1+4).Value)
End If
Next
Next
End If
If ws.name = "利润及分配表" Then
For n1 As Integer = 2 To 3
For n2 As Integer = 6 To 35
If ws.cells(n2+1,n1+1).Formula = "" Then
ws.cells(n2+1,n1+1).Value = val(Sheet3(n2,n1).Value)
End If
If ws.cells(n2+1,n1+5).Formula = "" Then
ws.cells(n2+1,n1+5).Value = val(Sheet3(n2,n1+4).Value)
End If
Next
Next
End If
If ws.name = "费用表" Then
For n1 As Integer = 3 To 6
For n2 As Integer = 4 To 32
If ws.cells(n2+1,n1+1).Formula = "" Then
ws.cells(n2+1,n1+1).Value = val(Sheet4(n2,n1).Value)
End If
Next
Next
End If
If ws.name = "工资月报" Then
For n1 As Integer = 3 To 4
For n2 As Integer = 4 To 24
If ws.cells(n2+1,n1+1).Formula = "" Then
ws.cells(n2+1,n1+1).Value = val(Sheet5(n2,n1).Value)
End If
Next
Next
End If
If ws.name = "附列资料" Then
For n1 As Integer = 1 To 13
For n2 As Integer = 2 To 19
If ws.cells(n2+1,n1+1).Formula = "" Then
ws.cells(n2+1,n1+1).Value = val(Sheet6(n2,n1).Value)
End If
Next
Next
End If
Next
代码中 If ws.name = "分户快报" Then,如何先判断“分户快报” 是否存在?