ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA - Max Function - Syntax Error (https://www.excelbanter.com/excel-programming/400626-excel-vba-max-function-syntax-error.html)

u473

Excel VBA - Max Function - Syntax Error
 
I cannot find the proper syntax for this Max Function
Assume the current Row# is 20. I want to populate H20 with the
Max(I20,M20,O20)
I have an Error whether I reverse the order of Columns-Rows reference
or not, but I am still in learning mode.
Dim LastRow As Long, ShNextRow As Long, Fcst As Long
With ActiveSheet
For ShNextRow = 10 To LastRow
Fcst = WorksheetFunction.Max(Range("I" & ShNextRow, "M" &
ShNextRow, "O" & ShNextRow))
.Range("H" & ShNextRow) = Fcst
Next ShNextRow
End With
Your help will be appreciated,
Wayne


OssieMac

Excel VBA - Max Function - Syntax Error
 
Hi Wayne,

Fcst = WorksheetFunction.Max(Cells(ShNextRow, "I"), _
Cells(ShNextRow, "M"), Cells(ShNextRow, "O"))

Regards,

OssieMac


"u473" wrote:

I cannot find the proper syntax for this Max Function
Assume the current Row# is 20. I want to populate H20 with the
Max(I20,M20,O20)
I have an Error whether I reverse the order of Columns-Rows reference
or not, but I am still in learning mode.
Dim LastRow As Long, ShNextRow As Long, Fcst As Long
With ActiveSheet
For ShNextRow = 10 To LastRow
Fcst = WorksheetFunction.Max(Range("I" & ShNextRow, "M" &
ShNextRow, "O" & ShNextRow))
.Range("H" & ShNextRow) = Fcst
Next ShNextRow
End With
Your help will be appreciated,
Wayne




All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com