Consulting

Results 1 to 6 of 6

Thread: OPEN a file,COPY a range and PASTE it

  1. #1

    OPEN a file,COPY a range and PASTE it

    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

  2. #2
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    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

  4. #4
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Try the attached to get you started. Put them in the same directory and run the runme.xls.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    and to browse use this for wb:

    [vba]Dim sFileName As String
    sFileName = Application.GetOpenFilename
    'They have cancelled.
    If sFileName = "False" Then Exit Sub
    Set wb = Workbooks.Open(sFileName)[/vba]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    THANKS SO MUCH LUCAS
    I'll try and tell you what's going on.
    greately appreciated

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •