AW: Daten aus geschlossener Mappe ???
18.02.2004 11:08:28
Hajo_Zi
Hallo Matthias
mit garnicht würde ich in VBA vorsichtig sein.
Option Explicit
' von Alf Herber Forum
' https://www.herber.de/forum/archiv/52to56/t52834.htm#52840
Sub TestGetValue()
Dim p As String
Dim f As String
Dim s As String
Dim r As String
p = "D:\Eigene Dateien\Hajo\"
f = "Adresse.xls"
s = "Adresse"
r = "B4"
MsgBox GetValue(p, f, s, r)
Worksheets("Tabelle1").Range("A1") = GetValue(p, f, s, r)
End Sub
Private Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
Dim arg As String
' Make sure the file exists
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If
' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
Bitte keine Mail, Probleme sollten im Forum gelöst werden.
Microsoft MVP für Excel
Das Forum lebt auch von den Rückmeldungen.
Betriebssystem XP Pro und Excel Version XP Pro