Gibt es eine Möglichkeit per Makro eine Seite aus einer anderen Mappe in die aktive Tabelle zu kopieren, ohne die andere Mappe zu öffnen?
Wenn ja, wie müßte der Makro-Befehl aussehen?
Für eure Hilfe vielen Dank!
Beste Grüße von Karsten
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