2016-05-23 34 views
0

它是否存在一種避免在vba中使用vlookup公式時取得四捨五入結果的方法。這裏是我的代碼:vlookup函數在vba中取整

Sub test() 
Dim lastrow, pressurecolumn, lastcolumn As String, total As Integer, x, row, irow, column As Double 
lastrow = Range("B8").End(xlDown).Value + 7 

Range("Pump_design[Total Pipe losses from plantroom]").ClearContents 
For Each row In Columns("EZ") 
For irow = 8 To lastrow 
total = 0 
For column = 4 To 153 
x = Cells(irow, column).Value 
If Not IsEmpty(x) Then 
total = total + Application.WorksheetFunction.VLookup(x, Sheets("Pump Design").Range("Pump_design"), 154, False) 
End If 
Next column 
Cells(irow, "EZ") = Round(total, 4) 
If Cells(irow, "EZ") = 0 Then Cells(irow, "EZ").ClearContents 
Next irow 
row = irow + 1 
Next row 
End Sub 

回答

0

剛剛發現的伎倆獲得總爲雙,而不是整數