It said error 13 type mismatch
Rich (BB code):
Sub Most_frequently_used_tools()
Dim strData As String
Dim item As String
Dim diameter As String
Dim rng As Range
Dim maximum As Variant
Dim rngCol As Range
Dim lngRow As Long
Dim rngAdd As Range
'Enter desired range in which to find the maximum value
strData = "Total_tools_out"
Set rng = Range(strData)
'Determines maximum value in range
maximum = Application.WorksheetFunction.Max(rng)
For Each rngCol In rng.Columns
'Returns row number of the maximum value, in the column which has the same
lngRow = Application.WorksheetFunction.Match(maximum, rngCol, 0)
'Returns cell address of the maximum value
Set rngAdd = rngCol.Cells(lngRow, 1)
'Selects smallest value to highlight with color
rngAdd.Select
With Selection
tools = Range("item").Value
End With
With Selection
diameter = Range("diameter").Value and point here
End With
With Selection
.Interior.Color = RGB(255, 140, 0)
End With
'Message displays the searched range, smallest value, and its address
MsgBox "Most frequently used tools is (""" & tools & """) and size is (""" & diameter & """) total used " & maximum & " number of tools."
Next
With Selection
.Interior.ColorIndex = 0
End With
End Sub
Last edited by a moderator: