troubleshooting Question

Excel VBA to copy specific worksheet to Active workbook

Avatar of DougDodge
DougDodge asked on
VBAMicrosoft Excel
2 Comments1 Solution292 ViewsLast Modified:
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
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros