急 急 急 =VLOOKUP($A6,法人買賣!A1:C200,3,FALSE) 請教諸位大大 VLOOKUP 函數在巨集內使用時, $A6 與 A1:C200 希望用變數,要如何寫 謝謝?

2017-01-29 3:27 am
更新1:

Cheng 大 您誤會了 "法人買賣!" 已經指向另一工作表了

回答 (2)

2017-01-29 10:20 am
Sub 巨集1()
For i = 6 To [A65536].End(3).Row
Range("B" & i).FormulaR1C1 = "=VLOOKUP(RC[-1],法人買賣!R1C1:R200C3,3,0)"
Next
End Sub

Sub test2()
Dim Rng As Range
Dim Cb As Variant
Dim Ca As String
Set Rng = Sheets("法人買賣").[A:C]
For i = 6 To [A65536].End(3).Row
Ca = Cells(i, 1)
Cb = Application.VLookup(Ca, Rng, 3, 0)
If Not IsError(Cb) Then
Cells(i, 2) = Cb
Else
Cells(i, 2) = ""
End If
Next
End Sub


收錄日期: 2021-05-03 13:50:04
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20170128192737AA0f3kT

檢視 Wayback Machine 備份