0

I've been trying this a lot of times but I don't get this working. What I want to achieve: Find the minimum value in a specific column F:F and then get me the row number (or range address) where this value is.

Note: Variable rngMinimumVariableEins has to be reformat because the value is very small.

Dim rngMinimumVariableEinsWert As Range Dim strResultValue As String Dim rngMinimumVariableEins As Range Set rngMinimumVariableEins = Worksheets("Berechnung").Range("F:F") rngMinimumVariableEins.NumberFormat = "0.00000000000000000000000000" strResultValue = Application.WorksheetFunction.Min(rngMinimumVariableEins) Debug.Print strResultValue Set rngMinimumVariableEinsWert = rngMinimumVariableEins.Find(strResultValue, LookIn:=xlValues, LookAt:=xlPart) If rngMinimumVariableEinsWert Is Nothing Then Debug.Print "No Results" Else Debug.Print rngMinimumVariableEinsWert.Row End If 

2 Answers 2

1

Excel worksheets have a 15 significant digit floating point limit and you can never reliably find a string that looks like a number in a column of true numbers.

dim minpos as variant with Worksheets("Berechnung").range("F:F") minpos = application.match(application.min(.cells.value2), .cells, 0) end with If iserror(minpos) Then Debug.Print "No Results" Else Debug.Print minpos End If 
Sign up to request clarification or add additional context in comments.

Comments

0

This is how you find the row number RowOfMin of the minimal value in a range RangeToSearch:

Option Explicit Public Sub FindMinimum() Dim RangeToSearch As Range Set RangeToSearch = Worksheets("Berechnung").Columns("F") Dim RowOfMin As Long On Error Resume Next With Application.WorksheetFunction RowOfMin = .Match(.Min(RangeToSearch), RangeToSearch, 0) End With On Error GoTo 0 If RowOfMin = 0 Then Debug.Print "No number values in column F" Else Debug.Print RowOfMin End If End Sub 

Note that you must avoid converting the minimum value into another datatype (e.g. by writing it into a variable) and instead use it directly for the .Match otherwise you will run into floating point issues.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.