此代碼檢查列G,如果它的值是「Test」,則在E列獲取相應的值並將其粘貼到下一行。如果不是Isempty返回「」值,但繼續下一個語句
Sub FindOpcode_Placepart()
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim destCol_part As Integer, destRow As Integer
Dim currentRowValue As String
Dim destRowValue As String
sourceCol_opcde = 7 ' find last row in column E
rowCount = Cells(Rows.Count, sourceCol_opcde).End(xlUp).Row
destCol_part = 5
destRow = Cells(Rows.Count, sourceCol_opcde).End(xlUp).Row
'for every row, find the Opcode
For currentRow = 1 To rowCount
If Cells(currentRow, sourceCol_opcde).Value = "Test" Then
destRowValue = Cells(currentRow, destCol_part).Text
If Not IsEmpty(destRowValue) Then ' this code returns "" value but proceeds with the next statement.
destRow = currentRow + 1
While Cells(destRow, sourceCol_opcde).Value = "Use-Limit"
Cells(destRow, destCol_part).Value = destRowValue
destRow = destRow + 1
Wend
End If
End If
Next
End Sub
感謝您的解釋。 :)我很喜歡這個網站! –