user2788201
user2788201

Reputation: 13

how to use max function for a range in excel using vb.net

i have a worksheet with some rows and columns

i want to paste maximum values from certain rows iteratively into a cell using vb.net

i write the code but it giving the error

please look in to this problem and guide me

           For i3 As Integer = 5 To rows2
                With oWs
                    **.cells(11, i3).formula = "=max(.range(E & i3 &  :  j & i3 ))"**

                End With
            Next

highlighted portion showing the error message

please guide me

gvg

Upvotes: 0

Views: 801

Answers (1)

John Bustos
John Bustos

Reputation: 19574

Your formula is a spreadhseet formula, not a VBA application.WorksheetFunction, so, therefore you need to enter it as text, not as a range - Try this:

.cells(11, i3).formula = "=max(E" & i3 & ":J" & i3 & ")"

Upvotes: 1

Related Questions