A
A
Alexey2018-01-30 08:53:25
Visual Basic
Alexey, 2018-01-30 08:53:25

How to create a macro for the minimum and maximum values ​​in a table?

Tell me how to create a macro for the maximum and minimum values?
There is this table
5a7007d0c982a077937813.jpeg
I tried to do it myself, but it turns out not quite right. Can anyone advise?

Sub Up()
Dim R As Long
R = InputBox("Задать номер строки")
With Worksheets("Лист1").Rows(R)
  MsgBox "Max" & WorksheetFunction.Max(.Cells) & vbNewLine & _
         "Min" & WorksheetFunction.Min(.Cells)
End With
End Sub

5a7008d6522a7178083302.jpeg
The result is this. How do I compare 2nd and 3rd column. So that, for example, a minimum value of 54.8 in 1998 was written in a cell or pop-up window.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question