AW: daten aus gschlossener mappe holen
29.03.2005 14:49:04
Hajo_Zi
Hallo Roland,
hast Du Dir für Deinen Level nicht ein wenig viel vorgenommen?
Option Explicit
' von Alf Herber Forum
' <a href="https://www.herber.de/forum/archiv/52to56/t52834.htm#52840">https://www.herber.de/forum/archiv/52to56/t52834.htm#52840</a>
Sub TestGetValue()
Dim p As String
Dim f As String
Dim s As String
Dim r As String
p = "E:\Eigene Dateien\Hajo\"
f = "Adresse.xls"
s = "Adresse"
r = "B4"
' bennanter Bereich ergänzung von Nikhil Milo
' r = "Heinze"
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)
' bennanter Bereich ergänzung von Nikhil Milo
' arg = "'" & path & "[" & file & "]" & sheet & "'!" & ref
' 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 Home SP2 und Excel Version 2003 SP1.