correct syntex for setting max function in excel

gvgbabu

Member
Joined
Sep 22, 2013
Messages
11
Programming Experience
Beginner
hi

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 wrote the code but it giving the error for bold text given below "Exception from HRESULT: 0x800A03EC"
please look in to this problem

For i3 As Integer = 5 To rows2

With oWs
.cells(11, i3).formula = "=max(.range(E & i3 & : j & i3 ))"


End With
Next

please guide me the correct way

gvg
 
In that code, everything inside the double quotes is literal text, so you are literally putting the text "i3" into the formula. If you want the value of a VB variable concatenated with some other text then that's what you actually have to do. Think about it. If you had this:
Dim name As String = "John Doe"
and you wanted to display a greeting to the user containing that name, how would you do it? You do this the same way.
 
Back
Top