我得到此代码工作一段时间,但最后几天它没有工作。从活动workbook1它假设进口sheetworkThisworkbook2:子程序,用于导入其代码片
Sub ImportallWBsh()
'https://michaelaustinfu.files.wordpress.com/2013/03/excel-vba-for-dummies-3rd-edition.pdf, Page 245
Dim Finfo As String
Dim FilterIndex As Integer
Dim Title As String
Dim Filename As Variant
Dim wb As Workbook
'Setup the list of file filters
Finfo = "Excel Files (*.xlsx),*xlsx,"
'Display *.* by default
FilterIndex = 1
'Set the dialog box caption
Title = "Select a File to Import"
'Get the Filename
Filename = Application.GetOpenFilename(Finfo, _
FilterIndex, Title)
'Handle return info from dialog box
If Filename = False Then
MsgBox "No file was selected."
Else
MsgBox "You selected " & Filename
End If
On Error Resume Next
Set wb = Workbooks.Open(Filename)
FilenameWorkbook.Sheets.Copy _
After:=ThisWorkbook.Sheets("Sheet3")
wb.Close True
ThisWorkbook.Sheets("Sheet1").Select
End Sub
你知道什么可能是错的。 谢谢
@ YowE3K - oops, 更正,谢谢。 – ashleedawg
我在阅读推荐的搜索和其他一些材料几天之后得到了代码。我真的很感谢谢谢。现在我想向您展示代码现在的样子如何获取更多的见解或建议我是否可以在此处编辑我的帖子,或者是否有任何其他方式可以在此处发布我的代码,以便您可以查看它?谢谢 – Sergio
不客气!嗯,好问题。正如你可能已经知道的,这里有些人对发布某些方式非常挑剔。 (今天别人的问题被删除了,因为** I **发布了一张图片作为答案,当时只是要求澄清!(我对这个问题提问者感觉不好)但是,我希望看到您的代码。我认为如果你编辑**你的原始问题,并在**结尾**处放置:“更新:”,并附上简短的解释和你的代码,那就没问题了。 – ashleedawg