Dim i As Integer
Range("d4:d2000") = "" '(清除舊有資料)
For i = 4 To 2000 '(決定有幾多行)
Range("D4").Select
Cells(i, "D") = "=VLOOKUP(""1002""&RC[-3],List!C[-3]:C[13],8,FALSE)"
Cells(i, "D") = Cells(i, "D").Value
Next i作者: mark15jill 時間: 2012-11-15 16:59
個人建議..
如果您要用VBA 寫法
可以不用拘束於 "=XXXXXX"
直接判斷就好..
例如
For i = 4 To ActiveSheet.Range("a4").CurrentRegion.Rows.Count
If (InStr(1, 工作表1.Cells(i, 1), "搜尋") >= 1) Then
工作表1.Cells(i, 7) = "find"
工作表1.Cells(i, 11) = InStr(工作表1.Cells(i, 1), "搜尋")
s = s + 1
else
工作表1.cells(i,7)=""
End If
For i = 4 To ActiveSheet.Range("a4").CurrentRegion.Rows.Count
If (InStr(1, Summary!.Cells(i, 1), "=VLOOKUP(""1002""&RC[-3],List!C[-3]:C[13],8,FALSE)") >= 1) Then
Summary!.Cells(i, 7) = "find"
Summary!.Cells(i, 11) = InStr(Summary!.Cells(i, 1), "=VLOOKUP(""1002""&RC[-3],List!C[-3]:C[13],8,FALSE)")
s = s + 1
Else
Summary!.Cells(i, 7) = ""
End If
Next
End Sub作者: JOSH 時間: 2012-11-15 17:35
大大~~ 請問我那裡錯了嗎?
請指導
謝謝
Sub h()
For i = 4 To ActiveSheet.Range("a4") ...
JOSH 發表於 2012-11-15 17:31
For i = 4 To ActiveSheet.Range("a4").CurrentRegion.Rows.Count
If (InStr(1, Summary!.Cells(i, 1), "=VLOOKUP(""1002""&RC[-3],List!C[-3]:C[13],8,FALSE)") >= 1) Then
Summary!.Cells(i, 7) = "find"
Summary!.Cells(i, 11) = InStr(Summary!.Cells(i, 1), "=VLOOKUP(""1002""&RC[-3],List!C[-3]:C[13],8,FALSE)")
s = s + 1
Else
Summary!.Cells(i, 7) = ""
End If