0
我想讓我的查找範圍動態,所以我使用變量col但我得到的是#N/A在結果列中。vba動態查找範圍
Private Sub CommandButton1_Click()
path3 = Application.GetOpenFilename(Title:="Please browse Output tab excel file")
Set wbs3 = Workbooks.Open(path3)
Set aCell1 = wbs3.Sheets("Output").Range("A1:X1").Find(What:="Functions", LookIn:=xlValues, LookAt:=xlPart, _
MatchCase:=False, SearchFormat:=False)
col = aCell1.Column
lastrow1 = wbs3.Sheets("Analysis").Columns("A").Cells.Find("*", SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious).Row
With wbs3.Sheets("Analysis").Range("I2:I" & lastrow1)
.Formula = "=VLOOKUP(H2,'Output'!col:col,1,0)"
.Value = .Value
End With
End Sub
感謝名單,它的工作 –