Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1244to1248
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
Inhaltsverzeichnis

Sortieren nach 1. Buchstaben/1.Ziffer

Sortieren nach 1. Buchstaben/1.Ziffer
Burghard
Hallo,
ich möchte den nachfolgenden VBA-Code etwas verändern und zwar soll nicht der gesamte Zellinhalt verglichen werden, sondern nur der 1. Buchstabe/die erste Ziffer:
Public Sub Leere_Zeile_bei_Wechsel_in_Spalte()
On Error GoTo nix
Dim lngRow As Long
Dim M As String
M = InputBox(prompt:=vbCr & vbCr & vbCr & vbCr & vbCr & "Hier die Spalte eingeben!", Title:= _
"Spalte?", xpos:="6250", ypos:="4200")
If M = "" Then GoTo nix
Application.ScreenUpdating = False
For lngRow = Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1
If Cells(lngRow, M).Value  Cells(lngRow - 1, M).Value And _
Not IsEmpty(Cells(lngRow, M)) And Not IsEmpty(Cells(lngRow - 1, M)) Then _
Rows(lngRow).Insert Shift:=xlShiftDown
Next
Application.ScreenUpdating = True
nix:
End Sub
Ich stelle mir das in etwa so vor:
Public Sub Leere_Zeile_bei_Wechsel_in_Spalte()
On Error GoTo nix
Dim lngRow As Long
Dim M As String
M = InputBox(prompt:=vbCr & vbCr & vbCr & vbCr & vbCr & "Hier die Spalte eingeben!", Title:= _
"Spalte?", xpos:="6250", ypos:="4200")
If M = "" Then GoTo nix
Application.ScreenUpdating = False
For lngRow = Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1
If Cells(lngRow, M).Value.Links(1)  Cells(lngRow - 1, M).Value.Links(1) And _
Not IsEmpty(Cells(lngRow, M)) And Not IsEmpty(Cells(lngRow - 1, M)) Then _
Rows(lngRow).Insert Shift:=xlShiftDown
Next
Application.ScreenUpdating = True
nix:
End Sub
Kann mir jemand den Code richtig schreiben? Danke im Voraus!
Schönen Gruß
Burghard

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Sortieren nach 1. Buchstaben/1.Ziffer
16.01.2012 12:29:26
Josef

Hallo Bzrghard,
If Left(Cells(lngRow, M), 1) <> Left(Cells(lngRow - 1, M), 1) And _
  Not IsEmpty(Cells(lngRow, M)) And Not IsEmpty(Cells(lngRow - 1, M)) Then _
  Rows(lngRow).Insert Shift:=xlShiftDown


« Gruß Sepp »

Anzeige
AW: klappt!
16.01.2012 13:21:57
Burghard
Hallo Sepp,
vielen Dank. Klappt einwandfrei!
Schönen Gruß
Burghard

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige