i have a problem. i have a workbook that contains database. i wanna calculate the averages of this database into new workbook. i was using record macro for make a button "input" in my workbook (database) and i wanna they show in my new workbook. this is my code that i make. can you correct my code and give me a solution for this? i need your help. thanks
Sub summary()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim wb As Workbook
Dim appExcel As Application
'create new excel application object
Set appExcel = New Application
'set the applications visible property to false
appExcel.Visible = False
Set wb = appExcel.Workbooks.Open("E:\tiga.xlsm")
Set ws1 = wb.Sheets(1)
Set ws2 = ThisWorkbook.Sheets(1)
With ws1
.Range("A3:A10").Formula = ws2.Range("D14")
.Range("B3:B10").Formula = "=AVERAGE($E$14:$E$30)"
.Range("C3:C10").Formula = "=AVERAGE($F$14:$F$30)"
.Range("D3:D10").Formula = "=AVERAGE($G$14:$G$30)"
.Range("E3:E10").Formula = "=AVERAGE($J$14:$J$30)"
.Range("F3:F10").Formula = "=AVERAGE($O$14:$O$30)"
End With
wb.Close SaveChanges:=False
appExcel.Quit
End Sub