what is the difference between MAX and Application.WorksheetFunction.Max ?

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
what is the difference between them.
If i know how many rows there are in a column I guess i can just use MAX, right?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
what is the difference between them.
If i know how many rows there are in a column I guess i can just use MAX, right?

Corrrect. In fact if you are in regular Excel, you SHOULD NOT use application.etc. That is for using MAX (or most other native Excel functions that do not have counterparts in VBA) in VBA
 
Upvote 0
can you help me with this?
Worksheets("sheet1").Range("C" & myColCheck).Value = Application.WorksheetFunction.Max(.Range(.Range(colPrevSheet2).End(xlUp), .Range(colPrevSheet2).End(xlUp).Offset(-(myActualRow - 1))))
colPrevSheet2 is just a letter for the column
myActualRow is the number of the elements in a column less one, because i don't want to count the first row.
How can i find the max for 'Worksheets("sheet1").Range("C" & myColCheck).Value =...'

in a previous post i've got this help

WorksheetFunction.Max(.Offset(1).Resize(.Rows.Count - 1))
</pre>
 
Upvote 0
No I didn't...
what is wrong with this?
Dim Rng As Range
Dim myMax As Integer
Rng = Worksheets("daily").Range(pIndex & "2" & ":" & pIndex & Lastrow)
myMax = WorksheetFunction.Max(Rng)
MsgBox myMax
actually with this
Rng = Worksheets("daily").Range(pIndex & "2" & ":" & pIndex & Lastrow)
 
Upvote 0
Looks like you want

Code:
Dim Rng As Range
Dim myMax As Variant
Set Rng = Worksheets("daily").Cells(2,pIndex).Resize(Lastrow - 1)
myMax = WorksheetFunction.Max(Rng)
MsgBox myMax
 
Upvote 0
why did you write
.Resize(Lastrow - 1)
I want to count from 2 row to the end.
So i guess with Cell(2,.... i have this and I don't need the Resize, right?
 
Upvote 0
right.
Set Rng1 = Worksheets("daily").Range(pIndex & "2" & ":" & pIndex & Range(Lastrow))
pIndex is a letter
Lastrow is a how many elements there are in column pIndex
I want to find the max from row2 to Lastrow of pIndex

I have an error on that line
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top