問題:查找多個值,串聯cooresponding在其他列中的值,寫入到小區
沒有被寫入到細胞在柱P的系的細胞(X,「P」)值= failingClasses應該這樣做。
說明:(以下VBA腳本)
我有ID號的列。每個ID號碼可以有多行。我需要做的是連接另一列中的所有對應值並將其寫入原始行中的單元格中。這需要爲工作表中的每一行完成。
字段1是其中的ID是,現場6是我想連接的信息,我想寫串聯成列P.
現在,我認爲計算是是正確完成,但由於什麼原因它不寫入P中的單元?
宏需要永遠運行。運行時在1k和2k行之間。
謝謝!
Worksheets("RAW GRADE DATA").Select
' Turn off auto calc update and screen update -- saves speed
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim x As Long, y As Long, totalGradeEntries As Long, failingClasses As String, failingClassesCell As Excel.Range
totalGradeEntries = Cells(Rows.Count, 1).End(xlUp).Row
For x = totalGradeEntries To 1 Step -1
failingClasses = ""
For y = totalGradeEntries To 1 Step -1
If Cells(y, 1).Value = Cells(x, 1).Value And Cells(x, 6) <> "02HR" Then
failingClasses = failingClasses & " " & Cells(y, 1).Value
End If
Cells(x, "P").Value = failingClasses
Next y
Next x
' Turn calc and screen update back on
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
雙循環是什麼殺死速度。這些ID總是連續的(排序)還是無序? (即無序123,155,123,143 ... 123由其他ID分隔) – 2014-10-31 20:04:45
1.在單元格(x,「P」)上放置一個斷點。值=行,並查看當時發生故障的類別。 2.只寫入單元格(x,「P」)一次 - 現在你正在寫每個內部循環。 3.要顯着提高速度,請在VBA陣列中執行「工作」,而不是在工作表上。 – 2014-10-31 20:13:49
波特蘭亞軍 - 我知道雙迴路正在殺死速度。這些ID是無序的,但我可以在循環運行之前做一個排序來解決這個問題。每個ID最多有9個條目。這可以幫助加速嗎? – 2014-10-31 20:29:39