我正在编写一个vba代码,该代码应该删除所选Excel工作表上的数据,打开一个文本文件选择对话框,然后将该文本文件中的数据导入到我从中删除数据的相同表单。到目前为止,我只能将文本文件打开到新的工作簿中,但无法将其打开到我从中删除数据的同一工作表。这是我到目前为止所提供的内容,非常感谢您的帮助:
Dim Filt As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As Variant
Filt = "Cst Files (*.prn),*.prn"
Title = "Select a cst File to Import"
FileName = Application.GetOpenFilename(FileFilter:=Filt, Title:=Title)
If FileName = False Then
MsgBox "No File Was Selected"
Exit Sub
End If
With Application.ActiveSheet
Cells.Select
Selection.QueryTable.Delete
Selection.ClearContents
End With
Workbooks.Open FileName
谢谢!
喵喵时光机
墨色风雨
POPMUISE