具有相同查找值的自动增量列索引(VLOOKUP)

时间:2015-10-15 12:30:43

标签: excel vlookup

所以我得到了以下查找:

= VLOOKUP(A20;员工:GE;柱(C:C); FALSE)

下一列应具有相同的查找值(A20),但COLUMN(D:D)应具有列索引号。这持续了几百列。

这可能吗?

1 个答案:

答案 0 :(得分:2)

是的,将此公式更改为$ 然后填写右侧。 Sub hr_test() Dim fileBrowse As FileDialog Dim shtNum As Integer Set fileBrowse = Application.FileDialog(msoFileDialogOpen) If fileBrowse.Show = True Then wbPath = fileBrowse.SelectedItems(1) With Workbooks.Open(wbPath) shtNum = InputBox("Enter the number of the sheet you want to use.") Sheets(shtNum).Activate Range("$A$1:$R$6523").AutoFilter Field:=3, Criteria1:= _ "=Global Commercial Services-Global 1", Operator:=xlOr, Criteria2:= _ "=Global Commercial Services-Global 2" Cells.Select Cells.EntireColumn.AutoFit Range("C4135").Select Columns("M:M").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Columns("B:B").Select Selection.Cut Range("M1").Select ActiveSheet.Paste Columns("B:B").Select Selection.Delete Shift:=xlToLeft Columns("Q:R").Select Selection.Delete Shift:=xlToLeft Range("R4130").Select Columns("B:B").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Columns("D:D").Select Selection.Cut Range("B1").Select ActiveSheet.Paste Columns("D:D").Select Selection.Delete Shift:=xlToLeft End With End Sub 会保持数字或列字母不变。