'按钮代码
Private Sub CommandButton1_Click()
Dim nPath$, nApp
nPath = "e:\mydoc\text.xlsx" '查询文件路径,自己更新
Set nApp = GetObject(nPath)
nApp.Sheets(1).Range("p:p").Copy ThisWorkbook.Sheets(1).Range("p1")
nApp.Close
Set nApp = Nothing
End Sub
'下面代码放到workbook 中
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets(1).Range("p:p") = ""
ThisWorkbook.Save
End Sub