+ Reply to Thread
Results 1 to 8 of 8

transfer of data between workbooks

Hybrid View

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    37

    transfer of data between workbooks

    I have data in sheet1 of workbook named test.xlsx.
    I need to copy the data in sheet1 of test.xlsx from A4:G4 to end and paste in sheet2 of workbook named sample.xlsx.
    I will be working in Sample.xlsx so i need the macro to copy from sheet1 of test.xlsx.
    The macro should ask for the test.xlsx file location and user should select the file through Browse.
    Once file test.xlsx is selected the said range of data should be copied and pasted in sheet2 range A3:G4 to end.
    Please help.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: transfer of data between workbooks

    Hi,

    This should do

    Sub steffen()
    
    Dim fileToOpen
    Dim wb As Workbook
    
    Set wb = ActiveWorkbook
    
    fileToOpen = Application.GetOpenFilename
    If fileToOpen = False Then
        MsgBox ("No file choosen")
    Else
        wb.Sheets(1).Range("A4:G" & wb.Sheets(1).UsedRange.Rows.Count).Copy Destination:=ActiveWorkbook.Sheets(2).Range("A4")
    End If
    
    End Sub
    Please take time to read the forum rules

  3. #3
    Registered User
    Join Date
    05-23-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: transfer of data between workbooks

    Thanks for your code...
    i used that code in file sample.xlsx.
    on execution it calls for location of file Test.xlsx
    after selection of file Test.xlsx from directory
    Nothing happens in file sample.xlsx

    Please note the sheet names
    Data to be copied from Sheet1 of Test.xlsx ( to seek from certain directory)
    Data to pasted in sheet name "Dell" of sample.xlsx. ( Active Workbook)

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: transfer of data between workbooks

    Hi

    Try this instead

    Sub steffen()
    
    Dim fileToOpen
    Dim wb As Workbook
    
    Set wb = ActiveWorkbook
    
    Workbooks.Open Application.GetOpenFilename
    wb.Sheets(1).Range("A4:G" & wb.Sheets(1).UsedRange.Rows.Count).Copy Destination:=ActiveWorkbook.Sheets(2).Range("A4")
    
    End Sub

  5. #5
    Registered User
    Join Date
    05-23-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: transfer of data between workbooks

    thanks for your efforts..

    but still not working.
    I m attaching both the files.
    kindly check from your end.
    I need the data to pasted in sheet name Dell of workbook sampl.xlsx.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: transfer of data between workbooks

    Ahh, i got the wrong way round

    Try this

    Sub steffen()
    
    Dim fileToOpen
    Dim wb As Workbook
    
    Set wb = ActiveWorkbook
    
    Workbooks.Open Application.GetOpenFilename
    ActiveWorkbook.Sheets(1).Range("A4:G" & ActiveWorkbook.Sheets(1).UsedRange.Rows.Count).Copy Destination:=wb.Sheets(2).Range("A4")
    wb.Sheets(2).Activate
    
    End Sub

  7. #7
    Registered User
    Join Date
    05-23-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: transfer of data between workbooks

    Thanks... Thanks.... Thanks....
    Working perfect....

  8. #8
    Registered User
    Join Date
    05-23-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: transfer of data between workbooks

    Thanks... Thanks.... Thanks....
    Working perfect....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1