3
我們在我們的辦公室中的一臺用戶機器上運行此代碼時出現問題 - 所有其他用戶計算機運行良好(Windows XP操作系統,Excel 2010 Standard或Professional) - 本機爲運行Excel 2010 Professional的Windows XP。運行時錯誤上線16次標有出現 - >問題似乎是變量i - 高亮提示顯示I = -1#INDExcel 2010雙變量運行時錯誤16
Sub FormatSheet(strResultSheet As String)
Dim oCol As Excel.Range
Dim i As Double
Dim R As String
Dim iColumn As Integer
' Special rountine to convert text column into numeric
Sheets(strResultSheet).Select
iColumn = 0
--> For i = 1 To Worksheets(strResultSheet).Cells.SpecialCells(xlLastCell).Column
If UCase(Cells(1, i).Text) = "QUANTITY" Then
iColumn = i
Exit For
End If
Next
Sheets(strResultSheet).Select
If iColumn > 0 Then
Columns(iColumn).Select
Selection.NumberFormat = "#,##0.00"
Selection.HorizontalAlignment = xlHAlignRight
For i = 2 To Sheets(strResultSheet).Cells.SpecialCells(xlLastCell).Row
If Cells(i, iColumn).Text <> "" Then
Cells(i, iColumn).Value = Cells(i, iColumn).Value * 1
End If
Next
End If
End Sub
任何人都知道我們需要做修復用戶機器。處理?宏嵌入在第三方日常電子郵件中,因此無法調整要修復的代碼。