PDA

View Full Version : OPEN a file,COPY a range and PASTE it



aysam
03-05-2010, 09:48 AM
PEACE to you all
I had a code from this VBA Express to open a file



With Application.FileDialog(msoFileDialogFilePicker)

.AllowMultiSelect = False
If .Show = -1 Then

Workbooks.Open (.SelectedItems(1))

End If
End With

I need to add a piece of code to copy a range from the opened file and paste to the main file starting at a certain row ( A1)
thanks in advance
greatly appreciated
AYSAM

lucas
03-05-2010, 09:56 AM
do you necessarily need to browse for this file?

Can it be hard coded or in the same directory as the file you are running the code from?

aysam
03-05-2010, 11:25 AM
What do you suggest?
I need to import some data from a closed file into the opened file
through a user form
Is it possible?I hope so .
may thanks
AYSAM

lucas
03-05-2010, 11:31 AM
Try the attached to get you started. Put them in the same directory and run the runme.xls.

lucas
03-05-2010, 12:04 PM
and to browse use this for wb:

Dim sFileName As String
sFileName = Application.GetOpenFilename
'They have cancelled.
If sFileName = "False" Then Exit Sub
Set wb = Workbooks.Open(sFileName)

aysam
03-05-2010, 12:21 PM
THANKS SO MUCH LUCAS
I'll try and tell you what's going on.
greately appreciated