Link to home
Create AccountLog in
Avatar of DougDodge
DougDodge

asked on

Excel VBA to copy specific worksheet to Active workbook

I am hoping to find code to copy cells of a workbook worksheet in sheet called "TASK", and paste into the active workbook. But ask the user which worksheet in the active workbook to copy to first.

So far the code I have uses the GetOpenFilename:

Sub FileDialogImport()

Dim strFileToOpen As String

strFileToOpen = Application.GetOpenFilename(Title:="Please Choose A File To Open For Import", FileFilter:="Excel Files *.xls* (*.xls*),")

If strFileToOpen = "" Then
    MsgBox "No File Selected.", vbExclamation, "Sorry!"
    Exit Sub
Else:
    Workbooks.Open Filename:=strFileToOpen
End If

End Sub

And the following to select the used range once the file is open:

Sub SelectDateToCopy()

ActiveSheet.UsedRange.Copy

End Sub

It does not matter if the source file is opened or not, I just want to copy the used range on the worksheet "TASK"

The user should be asked which sheet to paste to for a destination.

Hope I explained this well enough......
ASKER CERTIFIED SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.