I have this Walkenbach code that everybody uses to pull data from a closed workbook and it's working just fine for me:
Sub ImportData()
Dim p As String, f As String, s As String, a As String
p = "\\MyServer\MyFolder\MySubFolder"
f = "MyWorkbook.xlsx"
s = "MySheet"
a = "$A$1"
GetValue(p, f, s, a)
End Sub
Private Function GetValue(path, file, sheet, ref)
Dim arg As String
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If
arg = "'" & path & "[" & file & "]" & sheet & "'!" & Range(ref).Range("A1").Address(, , xlR1C1)
GetValue = ExecuteExcel4Macro(arg)
End Function
What I want to do is determine the interior color of each cell...if the manager of the source spreadsheet has changed the color of a cell, it indicates that the value within is invalid and should not be included in the analysis.
So currently 'arg' is set to...
'\\MyServer\MyFolder\MySubFolder\[MyWorkbook.xlsx]MySheet'!R1C1
and running ExecuteExcel4Macro
with that argument pulls the value in A1
.
How can I restructure the 'arg' assignment to pull the interior color instead of the value?
If necessary, I can ask the manager to change the font color instead of the interior color to mark data to be excluded.