我在這裏有一個宏的代碼,它執行一些數據選擇,並從一個工作表放置到另一個工作表。現在這個代碼完成了我想要的90%的功能。問題是,如果它遇到中有沒有(因此Len(cellVal) = 0
和cellVal = ""
它覆蓋目標單元格源小區。我如何讓excel vba移動到for循環中的下一個單元?
你會看到,在第二elseif的塊有一個註釋。現在它nothign但如果語句評估爲真,即是沒有在源小區,我希望Excel移動到下一個源小區不修改目標單元格中的內容。
如何這可能完成的任何想法?
富蘭克林
For i = 7 To endPointFlash
Dim cellVal As String
cellVal = Cells(i, "G")
If (Len(cellVal)) > 0 Then
RawData.Activate
ElseIf (Len(cellVal)) = 0 Or cellVal = "" Then
' need to tell excel to do nothing and move to the next cell
End If
For j = 1 To endPointRaw
If cellVal = Mid(Cells(j, "A"), 1, Len(cellVal)) Then
val2 = Mid(Cells(j, "A"), 1, Len(cellVal))
val3 = Cells(j, "D")
Flash.Cells(i, "H").Value = val3
Exit For
Else: Flash.Cells(i, "H").Value = 0
End If
Next j
Flash.Activate
Next i
你似乎更快了幾分鐘:-) – assylias 2012-02-16 09:08:10