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