[英]Vlookup cell background colour from another workbook VBA
我不確定你在做什么,但因為我有這個代碼......
Function Tester(rngLookup As Range, v)
Dim c As Range, f As Range, clr As Long
Set c = Application.ThisCell '<< the cell with the formula
Set f = rngLookup.Find(v, lookat:=xlWhole)
If Not f Is Nothing Then
clr = f.Interior.Color
Else
clr = vbWhite
End If
'change the background for the cell with the formula
Application.Evaluate "ChangeColor(""" & c.Parent.Name & """,""" & c.Address() & """," & clr & ")"
Tester = v 'or whatever is appropriate...
End Function
Sub ChangeColor(sht As String, addr As String, clr As Long)
ThisWorkbook.Sheets(sht).Range(addr).Interior.Color = clr
End Sub
示例用法(啟用顯示公式):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.