Good evening,
I am trying to import data from one workbook into another but it is not working. Any ideas on what is happening? This is something I am piecing together from other posts but I have hit a snag.
It works up until Windows(CFileName).activate![]()
Sub Updating() Dim ImportFileName as Variant Dim CFileNeams as Variant CFileName = ActiveWorkbook.Name MainMenu.Hide spath = CurDir ChDrive ThisWorkbook.Path ChDir ThisWorkbook.Path & "\Import File" ImportFileName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=False) If ImportFileName = False Then MsgBox "Error" MainMenu.Show Else Workbooks.Open Filename:=ImportFileName End If ImportFileName = ActiveWorkbook.Name Application.WindowState = xlMinimized Windows(ImportFileName).Activate Sheets("Setup1").Select Cells.Copy Windows(CFileName).Activate Sheets("Setup").Select Range("A1").PasteSpecial Paste:=xlPasteValues Application.WindowState = xlMaximized End Sub
I am not sure what is happening here as I have checked, using a message box, and CFileName still has the correct file name. For some reason excel will not switch to the other file. If I switch this to Windows("Workbooks name.xls").activate the code works.
Any ideas? As always, thank you in advance for your help!
tc











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks