Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
644to648
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
644to648
644to648
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Größte Zahl innerhalb Makro ermitteln

Größte Zahl innerhalb Makro ermitteln
31.07.2005 19:43:39
maik
Hallo allerseits,
kennt jemand von Euch im VBA eine Funktionsbezeichnung um die größte Zahl zu ermitteln?
ich habe die Funktion im Makro einmal wie folgt genannt um Euch das Problem zu verdeutlichen:
"Max(lz1, lz2, lz3, lz4)"
Anbei mein Quellcodeversuch:

Sub Makro3()
lz1 = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
lz2 = Cells.Find("*", [B1], , , xlByRows, xlPrevious).Row
lz3 = Cells.Find("*", [P1], , , xlByRows, xlPrevious).Row
lz4 = Cells.Find("*", [W1], , , xlByRows, xlPrevious).Row
For i = ****Max(lz1, lz2, lz3, lz4)**** To 4 Step -1
If Cells(i, 1).Value = "" Or Cells(i, 2).Value = "" Then
If Not (Cells(i, 1).Value = "" And Cells(i, 2).Value = "") Then
MsgBox i
Else
Cells(4, 1).Select
End If
End If
Next i
End Sub

Vielen Dank
Maik

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

Betreff
Datum
Anwender
Anzeige
AW: Größte Zahl innerhalb Makro ermitteln
31.07.2005 19:55:26
Josef
Hallo Maik!
Ich weis nicht ob ich dich richtig verstehe, aber vielleicht so!
Option Explicit

Sub Makro3()
    Dim lz1 As Long, lz2 As Long, lz3 As Long, lz4 As Long
    Dim i As Long, lMax As Long
    
    lz1 = Cells(65536, 1).End(xlUp).Row 'Spalte A
    lz2 = Cells(65536, 2).End(xlUp).Row 'Spalte B
    lz3 = Cells(65536, 16).End(xlUp).Row 'Spalte P
    lz4 = Cells(65536, 23).End(xlUp).Row 'Spalte W
    
    lMax = Application.Max(lz1, lz2, lz3, lz4)
    
    For i = lMax To 4 Step -1
        
        If Cells(i, 1).Value = "" Or Cells(i, 2).Value = "" Then
            If Not (Cells(i, 1).Value = "" And Cells(i, 2).Value = "") Then
                MsgBox i
            Else
                Cells(4, 1).Select
            End If
            
        End If
    Next i
    
End Sub


Gruß Sepp
P.S.: Rückmeldung nicht vergessen!


Anzeige
AW: Größte Zahl innerhalb Makro ermitteln
31.07.2005 20:03:30
maik
Hallo Sepp
das funktioniert einwandfrei!
danke

300 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige