Sub Button“j”_Click() |
‘ reading first file |
Dim xl As New Excel.Application |
Dim xlw As Excel.Workbook |
‘ Open the excel file. |
Set xlw = xl.Workbooks.Open(“C:∖Users∖ELEC462.xlsx”) |
xlw.Sheets (“ELEC462"). Select |
‘ Get the value from cell(2,3) of the sheet. |
‘ MsgBox xlw.Application.Cells(3, 2).Value |
Range (“C6”).Value = xlw.Application.Cells(19, 9).Value |
Range (“D6”).Value = xlw.Application.Cells(20, 9).Value |
Range (“E6”).Value = xlw.Application.Cells(21, 9).Value |
Range (“F6”).Value = xlw.Application.Cells(25, 7).Value |
‘ Close worksheet without save changes. |
‘ If you want to save changes, replace the False below with True |
xlw.Close False |
‘ free memory |
Set xlw = Nothing |
Set xl = Nothing |
‘reading 2nd file |
Dim xl2 As New Excel.Application |
Dim xlw2 As Excel.Workbook |
‘ Open the excel file. |
Set xlw2 = xl.Workbooks.Ope ("C:∖Users∖ELEC562.xlsx") |
xlw2.Sheets(“ELEC562").Select |
‘ Get the value from cell(2,3) of the sheet. |
‘ MsgBox xlw.Application.Cells(3, 2).Value |
Range(“C7”).Value = xlw2.Application.Cells(19, 9).Value |
Range(“D7”).Value = xlw2.Application.Cells(20, 9).Value |
Range(“E7”).Value = xlw2.Application.Cells(21, 9).Value |
Range(“F7”).Value = xlw2.Application.Cells(25, 7).Value |
‘ Close worksheet without save changes. |
‘ If you want to save changes, replace the False below with True |
xlw2.Close False |
‘ free memory |
Set xlw2 = Nothing |
Set xl2 = Nothing |
End Sub |