what i am trying to do is make a program to read an excel file that i already have , choose certin columns depending on its header title then paste these columns into sheet2 . the problem is when i check for the columns i want to extract it gives me this error "Object reference not set to an instance of an object".
this is the code i am using to extract the value of a certin cell while looping throw a row and if the value of the cell = "Sample" it changes the value of another cell with "Pass"..
Imports Excel = Microsoft.Office.Interop.Excel
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartTesting.Click
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
' start excel application
oXL = New Excel.Application
oXL.Visible = True
' Get a new workbook.
oWB = oXL.Workbooks.Open(C:\filepath.xls)
oSheet = oWB.ActiveSheet
' just to show me the value of the cell
MsgBox(oSheet.Cells(1, 1).Value.ToString, MsgBoxStyle.OkOnly)
' starting the loop
Dim i As Integer = 1
For i = 1 To 128
If oSheet.Cells(1, i).Value.ToString = "Sample" Then
oSheet.Cells(2, 1) = "Pass"
I have a graph in my excel file. There is two values that changes this graph appearance, so I want to change these cell values in a FOR loop, in order to make a "animation". Is it work? Every step of the loop will change the graph, but how can I be abke to see it changing? Anyone can help mein this doubt?