0
我已經在excel中寫了一個宏,有時宏的工作方式應該是這樣,但大約40%的時間掛在完整的excel上,沒有任何反應。我試圖通過和大部分時間,我發現在3個特定語句的宏手。有人可以告訴我什麼可能是我做錯的確切的事情,或者如何更好地使宏觀更強健和穩定。Excel宏掛了一段時間
這裏是從宏代碼:
Sub fastcloudextractor()
'
' fastcloud extractor Macro
'
' defenitions
Dim data_arr() As Variant, temp_arr() As Variant
Dim i As Long, j As Long, k As Long, curent_item As Long
Dim pctCompl As Integer, err As Integer, total_items As Integer
Application.ScreenUpdating = False
err = 2
'
' get data row count and load data into array
'
Sheets("Original").Select
data_count = Range("A1").End(xlDown).Row
data_count = data_count + 1
Cells(data_count, 1) = 1
Cells(data_count, 5) = 1
data_arr = Range(Cells(2, 5), Cells(data_count, 14))
' without Below 2 Lines the program gives a error
'
Sheets("sheet4").Select
temp_arr = Range(Cells(1, 1), Cells(data_count, 10))
' ----- Begin new code -----
k = 1
current_item = data_arr(1, 1)
' Debug.Print current_item
For j = LBound(data_arr) To UBound(data_arr)
If data_arr(j, 1) = current_item Then
do some thing
Else
Do some thing else
End If
k = k + 1
Next j
Erase temp_arr
Erase data_arr
Sheets("Original").Select
Range("A2:N2").Select
Sheets("Unique").Select
Range("A2").Select
Sheets("Selected").Select
Range("A1").Select
Sheets("Compiled").Select
Range("A2").Select
Sheets("Extracted").Select
Range("A1").Select
Sheets("Magmi").Select
Application.ScreenUpdating = True
Application.StatusBar = False
Beep
MsgBox "Data Conversion Completed" & vbCr & "Total no of products is .." & total_items
End Sub
宏掛起通常在
data_arr = Range(Cells(2, 5), Cells(data_count, 14))
或
temp_arr = Range(Cells(1, 1), Cells(data_count, 10))
有人可以幫助我確定我做錯了什麼以及如何糾正它。
我仍然是一個新手,所以如果更正提到kindly給代碼示例。
A1或第一行有標題,我不會處理。所以基本上數據將來自A2。這不會是空白的 – iSrini