bearcub
Well-known Member
- Joined
- May 18, 2005
- Messages
- 734
- Office Version
- 365
- 2013
- 2010
- 2007
- Platform
- Windows
I have file where I want to open an existing file, select a sheet, copy this sheet and paste onto the sheet which is housing the macro.
This is what I have so far using the macro recorder. I've been searching online for something that is dynamic but a lot of the code I've seen doesn't allow me to select the destination worksheet or allow me to go to a destination of my choice.
I realize this is inefficient (since I'm using the recorder):
This is what I have so far using the macro recorder. I've been searching online for something that is dynamic but a lot of the code I've seen doesn't allow me to select the destination worksheet or allow me to go to a destination of my choice.
I realize this is inefficient (since I'm using the recorder):
Code:
Sub PasteFalconData()
Dim wkbk As Workbook
Set wkbk = ThisWorkbook
Application.FileDialog(msoFileDialogFilePicker).Show
Workbooks(activework).Activate
ActiveCell.Cells.Select
Selection.Copy
wkbk.Activate
Sheets("Extract").ClearContents
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
[code]/
I want to open the open dialog box->select a file->open that file-> select and copy a sheet in that file->activate the file where the data is to be pasted ->close this file ->clear the destination sheet -> paste the data that was just copied from the file that was just opened (and close). I'm lost as to open the workbook that I've selected using the file picker (or show it be the folder picker). I using 2016 and the file I'm looking for will be either an xlsx file or a xlsb file (or maybe a CSV). I'm creating a template for our admins to use.
Thank you for your help.
Michael