I created a code in VBnet to insert data into an excel column, then first it validates if in the left column there is some data, if yes it should enter data, if it does not exit the condition while
Dim num As Int32 = 2
Dim HValue As String = xlWorksheet.Range(“H”+num.ToString).Value.ToString
While HValue <> "" xlWorksheet.Range("J"+num.ToString).Value = "=Sum(H"+num.ToString +"/L"+num.ToString+")" num = num + 1 HValue = xlWorksheet.Range("H"+num.ToString).Value.ToString End While
this is the result:
the codes within while work, but when the result of while is failed it returns the following error to me:
Invoke code: Exception has been thrown by the target of an invocation.