Thema Datum  Von Nutzer Rating
Antwort
26.07.2016 07:20:27 Sascha
NotSolved
27.07.2016 21:19:50 Gast50903
NotSolved
01.08.2016 08:12:54 Sascha
NotSolved
Blau Makro erweitern
02.08.2016 23:20:27 Gast94931
NotSolved

Ansicht des Beitrags:
Von:
Gast94931
Datum:
02.08.2016 23:20:27
Views:
828
Rating: Antwort:
  Ja
Thema:
Makro erweitern

Hallo,

okidoki, die Hitzewelle ist vorbei, also hier mal ein zweiter Ansatz, Du hattest jetzt ja idealerweise Daten mitgeliefert, da kann man nach einem zweiten Schlüsselwort ('Instrument') suchen...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Option Explicit
 
Public Sub test()
  Const LAST_COLUMN As Long = 9  '// Tabellen-Block-Breite SourceSheet
  Const SEARCH_STRING As String = "Objekt" '// Suchtext Tabellenname
  Const SEARCH_STRING_2 As String = "Instrument" '// Suchtext Tabellenende
  Dim wksSheet As Worksheet
  Dim objStartCell As Range, objLastCell As Range
  Dim strChars As String
  Dim lngIndex As Long, lngHeaderColor As Long
  lngHeaderColor = RGB(210, 210, 210) '// Header-Color
  strChars = ": 0" '// Objekt-Bez. SourceSheet
  On Error GoTo Sub_Exit
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  For Each wksSheet In ThisWorkbook.Worksheets
     With wksSheet
         If .Name Like SEARCH_STRING & "*" Then Call .Delete
     End With
  Next
  Application.DisplayAlerts = True
  Set wksSheet = ThisWorkbook.Worksheets("ET-Utility Report")
    Do
        lngIndex = lngIndex + 1
        If lngIndex > 9 Then strChars = ": "
              With ThisWorkbook.Worksheets("ET-Utility Report")
                  Set objStartCell = .Cells.Find( _
                      What:=SEARCH_STRING & strChars & lngIndex, LookIn:=xlValues, _
                        LookAt:=xlWhole, MatchCase:=False)
                  If Not objStartCell Is Nothing Then
                    If lngIndex > 8 Then strChars = ": "
                    Set objLastCell = .Cells.Find( _
                      What:=SEARCH_STRING & strChars & lngIndex + 1, LookIn:=xlValues, _
                        LookAt:=xlWhole, MatchCase:=False)
                    If Not objLastCell Is Nothing Then
                      With objStartCell
                            If .Offset(-1, 0).Interior.Color <> lngHeaderColor Then
                              Set objStartCell = .Offset(-2, 0)
                            Else
                              Set objStartCell = .Offset(-1, 0)
                            End If
                      End With
                      Set objLastCell = .Range(objLastCell, objLastCell.Offset(-10, 0)).Find( _
                         What:=SEARCH_STRING_2, LookIn:=xlValues, _
                         LookAt:=xlWhole, SearchDirection:=xlPrevious, MatchCase:=False)
                    Else
                      Set objLastCell = .Range(objStartCell, .Cells(.Cells(.Rows.Count, 2).End(xlUp).Row, _
                         objStartCell.Column)).Find(What:=SEARCH_STRING_2, LookIn:=xlValues, _
                           LookAt:=xlWhole, SearchDirection:=xlPrevious, MatchCase:=False)
                      If Not objLastCell Is Nothing Then
                         Set objStartCell = objStartCell.Offset(-1, 0)
                      Else
                         Call MsgBox("Der Suchwert ist nicht vorhanden....", vbExclamation)
                      End If
                    End If
                      Set wksSheet = ThisWorkbook.Worksheets.Add(After:=wksSheet)
                      With wksSheet
                            .Name = SEARCH_STRING & " " & lngIndex
                            .Columns("B:I").ColumnWidth = 8.88
                            .Columns("J").ColumnWidth = 0.92
                      End With
                      Call .Range(objStartCell, .Cells(objLastCell.Row, LAST_COLUMN + 1)).Copy( _
                          Destination:=wksSheet.Cells(2, 2))
                      Set objLastCell = Nothing
                  End If
              End With
    Loop Until objStartCell Is Nothing
    If lngIndex = 1 Then Call MsgBox("Der Suchwert ist nicht vorhanden....", vbExclamation)
    Call MsgBox("Es wurden " & lngIndex - 1 & " Objekt-Blätter erstellt.", vbExclamation)
Sub_Exit:
    If Err.Number <> 0 Then Call MsgBox("Error: " & _
        Err.Number & " " & Err.Description)
    Set wksSheet = Nothing
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End Sub

Gruß,


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
26.07.2016 07:20:27 Sascha
NotSolved
27.07.2016 21:19:50 Gast50903
NotSolved
01.08.2016 08:12:54 Sascha
NotSolved
Blau Makro erweitern
02.08.2016 23:20:27 Gast94931
NotSolved