Close in einer Schelife??

  • Excel

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von alchimist.

    Close in einer Schelife??

    HuHu, Leute
    :D :D :D :D
    So machen wir's schnell und schmerzlos ...
    Ich will in der Schleife alle geöffneten Tabellen
    schließen außer die HauptTabelle (test lücken.xls)...


    Kann mir jeamdn weiter helfen?

    Quellcode

    1. Dim FileName(1 To 2000) As String
    2. Dim MaxTab As Integer
    3. Sub Main()
    4. Call Msg
    5. Call Scopy
    6. End Sub
    7. Sub Scopy()
    8. ChDir "D:\*****\******\"
    9. '
    10. For I = 1 To MaxTab
    11. Workbooks.Open FileName:=FileName(I)
    12. Application.CutCopyMode = False
    13. Range("A5:A5").Select
    14. Selection.Value = ActiveWorkbook.Name
    15. Range("A5").Select
    16. Text1 = ActiveCell.Value
    17. Range("B5:L12").Select
    18. Selection.Copy
    19. Windows("test lücken.xls").Activate
    20. Zeile = (5 + (I - 1) * 8)
    21. Range(Cells(Zeile, 2), Cells(Zeile, 12)).Select
    22. ActiveSheet.Paste
    23. Range(Cells(Zeile, 1), Cells(Zeile, 1)).Select
    24. ActiveCell.Value = Text1
    25. Next I
    26. End Sub
    27. Sub Msg()
    28. Set fs = Application.FileSearch
    29. With fs
    30. .LookIn = "D:\****\*****\"
    31. .FileName = "*.xls"
    32. MaxTab = fs.FoundFiles.Count
    33. If .Execute(SortBy:=msoSortByFileName) > 0 Then
    34. For I = 1 To .FoundFiles.Count
    35. ' MsgBox .FoundFiles(I)
    36. FileName(I) = fs.FoundFiles(I)
    37. Next I
    38. Else
    39. MsgBox "There were no files found."
    40. End If
    41. End With
    42. End Sub


    \\\\\\\\\\\\\ EDIT\\\\\\\\\\\\\\\\\\\

    HAT SICH GEKLÄRT!

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „Kennyger“ ()

    Hallo,

    keinen Plan, was dein Quelltext mit der Frage zu tun hat, eine mögliche Antwort könnte so aussehen:

    Visual Basic-Quellcode

    1. Dim oWbk As Workbook
    2. For Each oWbk In Workbooks
    3. If Not oWbk.Name = "Mappe1" Then oWbk.Close
    4. Next oWbk


    Gruß Markus

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „alchimist“ ()