I start my code in 1 workbook, this code will open a file in another workbook so i can copy information to my main workbook, i would like to close the 2nd workbook once i'm done with it.
'Load the CSV file from the selected path.. Workbooks.Open Filename:=CSVfile, Origin:=xlWindows If IsEmpty(Range("A2")) Or IsEmpty(Range("AG2")) Then Message = "The CSV was not a FULL CSV file." Message = Message & "Plaese use the ADHOC Query to obtain a full file" MsgBox Message, vbOKOnly, "Problem with CSV file!" Quiting = True Exit Sub End If Cells.Select Selection.Copy Set Sourcebook = ActiveWorkbook Workbooks("Calculate_XP.xls").Activate Worksheets("Import Sheet").Select Range("A1").Select ActiveCell.PasteSpecial Cells.Select With Selection.Font .Name = "Comic Sans MS" .Size = 8 End With Columns("A:AZ").AutoFit With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom End With 'Workbooks(Sourcebook).Activate 'ActiveWindow.Close
i can't seem to get the last 2 lines to work. i have set 'sourcebook' to be a workbook at the beginning of the macro.
any thought would help
Thanks Brian G.