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?
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
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
 

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
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>
 

earp_

Active Member
Joined
Apr 30, 2008
Messages
305

ADVERTISEMENT

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)
 

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
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
 

earp_

Active Member
Joined
Apr 30, 2008
Messages
305

ADVERTISEMENT

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?
 

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
We need more info, more context to sort that out.
 

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
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:

Watch MrExcel Video

Forum statistics

Threads
1,122,669
Messages
5,597,474
Members
414,145
Latest member
lonnie451

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
Top