View Single Post
 
Old 09-07-2012, 09:30 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi johanna,

In your 'modul1', try replacing the three 'If strFile <> CStr(False) Then' blocks with one block coded as:
Code:
If strFile <> CStr(False) Then
  Set objWB = Workbooks.Open(strFile)
  For Each objSh In ThisWorkbook.Worksheets
    If objSh.Name <> "Übersicht" Then
      If SheetExist(objSh.Name, objWB) = False Then
        Set objNewSh = ThisWorkbook.Sheets.Add
        objNewSh.Name = Split(objWB.Name, ".")(0)
      End If
      objSh.Range("g7") = objWB.Sheets(objSh.Name).Range("g7").Value
      objSh.Range("C12:I28") = objWB.Sheets(objSh.Name).Range("C12:I28").Value
      objSh.Range("b7") = objWB.Sheets(objSh.Name).Range("b7").Value
    End If
  Next
  objWB.Close False
End If
In your 'modul2', try replacing the two 'If strFile <> CStr(False) Then' blocks with one block coded as:
Code:
If strFile <> CStr(False) Then
  Set objWB = Workbooks.Open(strFile)
  For Each objSh In ThisWorkbook.Worksheets
    If objSh.Name <> "Übersicht" Then
      If SheetExist(objSh.Name, objWB) = False Then
        Set objNewSh = ThisWorkbook.Sheets.Add
        objNewSh.Name = Split(objWB.Name, ".")(0)
      End If
      objSh.Range("p7") = objWB.Sheets(objSh.Name).Range("g7").Value
      objSh.Range("L12:R28") = objWB.Sheets(objSh.Name).Range("C12:I28").Value
    End If
  Next
  objWB.Close False
End If
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote