Use of worksheet function

Caze982

Board Regular
Joined
May 10, 2015
Messages
77
[FONT=&quot]Hi[/FONT]
[FONT=&quot]I want to use the min method of the WorksheetFunction on a range in a workbook in sheet 1, and assing the value to a variable called lastrow, like the following:[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]LowestScore = Excel.Application.Workbooks(1).Worksheets(1).WorksheetFunction.Min(Range("B1:B5"))[/FONT]
[FONT=&quot]but i get an error 438 that says that object dosen't support this property or method.[/FONT]
[FONT=&quot]I am pretty sure that it is because that worksheet function is not at property of worksheets class.[/FONT]
[FONT=&quot]In the object browser i can see that WorksheetFunction is a property of the application class.[/FONT]
[FONT=&quot]My question is, how can i, in my code spcify in which sheet i want to use the worksheet function?[/FONT]
[FONT=&quot]As above i would think it would be:[/FONT]
[FONT=&quot]Excel.Application.Workbooks(1).Worksheets(1).WorksheetFunction.Min(Range("B1:B5"))[/FONT]
[FONT=&quot]Excel.Application.Workbooks(1).Worksheets(2).WorksheetFunction.Min(Range("B1:B5"))[/FONT]
[FONT=&quot]Excel.Application.Workbooks(1).Worksheets(3).WorksheetFunction.Min(Range("B1:B5"))[/FONT]
[FONT=&quot]Sincerly[/FONT]
[FONT=&quot]Christian[/FONT]
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It should be:

Code:
LowestScore = Excel.Application.WorksheetFunction.Min(Workbooks(1).Worksheets(1).Range("B1:B5"))
 
Upvote 0
Try adding it in the last part (Range):

Application.WorksheetFunction.Min(Workbooks(1).WorkSheets(1).Range("B1:B5"))

RoryA was faster, I can't delete my post now...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

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