也許有點難看,但你可以用這樣一個公式來完成,在Master!F1
:
=IFERROR(VLOOKUP(A1,Processor1!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor2!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor3!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor4!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor5!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor6!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor7!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor8!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor9!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor10!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor11!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor12!A:F,6,FALSE),
IFERROR(VLOOKUP(A1,Processor13!A:F,6,FALSE),
"")))))))))))))
然後複製/粘貼在主表的F欄中。
VBA
好了,廚師想它VBA,可能是因爲他(她)doesnt't希望公式減緩與工作簿工作。那麼,我會在VBA中設置F
列的公式,然後修改這些值。
Sub ColumnF()
Application.EnableEvents = False: Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual
On Error GoTo Cleanup
With Worksheets("Master")
With .Range("A1", .Cells(.Rows.count, 1).End(xlUp)).offset(, 5)
.Formula = "=IFERROR(VLOOKUP(A1,Processor1!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor2!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor3!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor4!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor5!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor6!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor7!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor8!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor9!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor10!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor11!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor12!A:F,6,FALSE)," & _
"IFERROR(VLOOKUP(A1,Processor13!A:F,6,FALSE)," & _
""""")))))))))))))"
.Value = .Value ' remove formula and freeze value
End With
End With
Cleanup:
Application.Calculation = xlCalculationAutomatic: Application.ScreenUpdating = True: Application.EnableEvents = True
End Sub
這應該比在A列的所有單元上的VBA循環更好更快;首先是因爲它使用Excel的內置功能而不是VBA循環,其次是因爲它最大限度地減少了VBA和Excel之間的交換。
發佈您已編寫的代碼(工作或不!)。 – Jeeped
我可以在早上,但我現在在家裏的電腦 - 將不得不等待,直到我開始工作 – mbillion
@Jeeped你是對的這個問題看起來離題爲VBA代碼,我的答案開始於一個公式,我認爲「簡單」,但隨後OP說他已經擁有了它,但想要VBA。那麼....:D –