I'm pretty new to Visual Basic, so any help will be greatly appreciated!!! I have two different excel sheets with pretty much the same information but with updateddata in one of the columns(one excel sheet is from this week and one from last week). I'm trying to take this week'ssheet and subtract column B's information from column B's information from last week's sheet and copy the results into a new excel workbook. I'm creating an application with this happening on the Button Click event. I'm not really sure what to do next, help me please!
I have referenced the Excel Object Library so that I can control excel through VB and I know its incomplete but I have this so far...
Dim cn1 As System.Data.OleDb.OleDbConnection
Dim cn2 As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbDataAdapter
Dim ds As New System.Data.DataSet()
Dim NewSheet as New Excel.Application
cn1 = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=C:\thisWeek.XLS;Extended Properties=Excel 8.0;")
cn2 =New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=C:\lastWeek.XLS;Extended Properties=Excel 8.0;")
cmd = New System.Data.OleDb.OleDbDataAdapter("select * from [thisWeek$]", cn1)
cn1.Open()
cmd.Fill(ds)
NewSheet.xls=ds.copy
cn1.close()
cn2.close()
Can I just put and excel formula in my code to directly referece these two columns in their respective sheets and compute it that way? Then output into a new sheet?