Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
716to720
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
716to720
716to720
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

suche nach string "total"

suche nach string "total"
10.01.2006 00:50:17
mehmet
hallo forum,
in tabelle "volmat" stehen in spalte a, b, c und d sowohl
text als auch zahlen.
mittels makro:
soll eine neue arbeitsmappe eingefügt werden (name soll "tab1" sein).
die tabelle "volmat" spalte b1 bis endschleife "grand total"
nach dem string "total" gesucht werden.
das problem dabei ist, das in spalte b der string "total" immer
am ende einer zelle steht.
wenn diese gefunden wird, sollen die zeilen a, b, c und d in
die neue tabelle "tab1" - beginnend zeile 2, eingefügt werden.
ich hoffe, dass ich mich verstaendlich ausdrucken konnte
dank und gruss

bsp auszug tabelle "volmat"
a          b                c         d
1     leer       text            zahl      zahl
2     leer       hallo total       12        35
3     was        du da total       23        33
4     leer       und du            45        76
5     jetzt      und total         35        65
6     jaein      komm total        34        43
7     leer       was               34        76
.     leer       grand total     1232     43345

8
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: suche nach string "total"
10.01.2006 07:37:26
bst
Morgen mehmet,
versuch's mal so.
cu, Bernd
--
Option Explicit

Sub UmKopieren()
   Dim i&, j&, src As Worksheet
   
   Set src = Worksheets("volmat")
   Worksheets.Add(after:=src).Name = "tab1"
   j = 2
   With src
      For i = 2 To .Cells(.Rows.Count, 2).End(xlUp).Row
         If .Cells(i, 2).Value Like "*total" Then
            .Range(.Cells(i, 1), .Cells(i, 4)).Copy Cells(j, 1)
            j = j + 1
         End If
      Next
   End With
End Sub

Anzeige
AW: suche nach string "total"
10.01.2006 12:19:20
mehmet
hallo bernd
dank dir für deine antwort
es wird eine neue tabelle erstellt "tab1"
das wars den auch leider
danach passiert nichts
gruss
mehmet
AW: suche nach string "total"
10.01.2006 13:32:05
mehmet
hallo bernd
komisch! ich werde mal versuchen nachzuvollziehen warum es nicht im ori.datei
nicht geht
dank dir
gruss
mehmet
AW: suche nach string "total"
10.01.2006 13:48:13
mehmet
hallo bernd
ich steig nicht dahinter! :(
ich lade die datei hoch ohne makro
https://www.herber.de/bbs/user/29891.xls
dank im voraus
gruss
mehmet
Anzeige
AW: suche nach string "total"
10.01.2006 14:21:29
bst
Hi mehmet,
Für Like ist im Default-Fall (Option Compare Binary) "total" ungleich "Total".
Ändere dies entsprechend im Source oder nimm - am Anfang des Moduls - zusätzlich sowas:
Option Compare Text
Siehe VBA-Hilfe zu LIKE.
cu, Bernd
AW: suche nach string "total"
10.01.2006 14:42:05
bst
Nochmals Hi,
Da Du vermutlich nicht die Zellen kopieren möchtest sondern deren Inhalte nimm vielleicht besser sowas:
Option Explicit
Option Compare Text

Sub UmKopieren()
   Dim i&, j&, src As Worksheet, arr As Variant
   
   Set src = Worksheets("volmat")
   Worksheets.Add(after:=src).Name = "tab1"
   j = 2
   With src
      For i = 2 To .Cells(.Rows.Count, 2).End(xlUp).Row
         If .Cells(i, 2).Value Like "*total" Then
            arr = .Range(.Cells(i, 1), .Cells(i, 4))
            Range(Cells(j, 1), Cells(j, 4)) = arr
            j = j + 1
         End If
      Next
   End With
End Sub

Oder - IMHO etwas verständlicher - auch sowas:
Option Explicit
Option Compare Text

Sub UmKopieren2()
   Dim i&, j&, src As Worksheet, k%
   
   Set src = Worksheets("volmat")
   Worksheets.Add(after:=src).Name = "tab1"
   j = 2
   With src
      For i = 2 To .Cells(.Rows.Count, 2).End(xlUp).Row
         If .Cells(i, 2).Value Like "*total" Then
            For k = 1 To 4
               Cells(j, k) = .Cells(i, k)
            Next
            j = j + 1
         End If
      Next
   End With
End Sub


HTH, Bernd
Anzeige
AW: suche nach string "total"
10.01.2006 16:46:24
mehmet
super bernd
dank dir, es funktioniert
herzliche grüsse aus köln
gruss
mehmet

300 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige