AW: Letzten positiven Wert aus Spalte in MsgBox
25.06.2013 10:16:14
Peter
Hallo Nils,
als eigenständiges Makro so:
Option Explicit
Public Sub Positiver_Wert()
Dim WkSh As Worksheet
Dim lZeile As Long
Dim iSpalte As Integer
Set WkSh = ThisWorkbook.Worksheets("Tabelle1") ' den Tabellenblattnamen ggf. anpassen
iSpalte = 1 ' die Spalte (hier A) festlegen
With WkSh
For lZeile = .Cells(.Rows.Count, iSpalte).End(xlUp).Row To 1 Step -1
If IsNumeric(.Cells(lZeile, iSpalte).Value) Then
If .Cells(lZeile, iSpalte).Value >= 0 Then
MsgBox "Die Zelle in Zeile " & lZeile & vbLf & _
"enthält den Wert " & Format(.Cells(lZeile, iSpalte).Value, "0.00")
Exit For
End If
End If
Next lZeile
End With
End Sub
Gruß Peter