-
Nice, this code now works, I call the script from a button on sheet 2.
It copies the 1st sheet of the opened file and places it before the sheet named "-----3".
My next question is, how do I make the imported sheet overwrite a sheet if one of the same name exists?
i.e. i want to be able to import the sheet if any changes are made, but dont want endless copies such as data, data(1), data(2) etc.
[vba]Sub mpImport_data()
Dim mpFilename As Variant
Dim mpWorkbookData As Workbook
Dim mpWorkbookCurrent As Workbook
mpFilename = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
Set mpWorkbookCurrent = ActiveWorkbook
Set mpWorkbookData = Workbooks.Open(mpFilename)
mpWorkbookData.Sheets(1).Copy mpWorkbookCurrent.Worksheets("-----3")
mpWorkbookData.Close
Sheets(2).Select
End Sub[/vba]
Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules