Results 1 to 5 of 5

macro to transfer data from one file to another

Threaded View

sha_ch macro to transfer data from... 06-20-2010, 12:00 AM
royUK Re: macro to transfer data... 06-20-2010, 03:27 AM
sha_ch Re: macro to transfer data... 06-20-2010, 09:44 PM
royUK Re: macro to transfer data... 06-21-2010, 01:03 AM
royUK Re: macro to transfer data... 06-22-2010, 12:31 AM
  1. #1
    Registered User
    Join Date
    06-19-2010
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question macro to transfer data from one file to another

    I'm new to vba programming and was trying to make a pc of code using bits of info from the net, but it isn't working. pls some one help me write it.

    problem:
    i have two files a.xls and b.xls . in a.xls (sheet 1) there is a column(column A) with names of people. And in b.xls(sheet 1) in column A there is a longer list of names and in column B their phone nos. i want to write a vba code to take each name in a.xls and find it in b.xls and take the phone no. from b.xls and write it into the first file.

    this is the code iv written, you may correct it or write ur own:
     Sub macro1()
    
    ThisWorkbook.Activate
    ActiveSheet.Name = file1
    
    rows = ActiveSheet.UsedRange.Rows.Count
    
    For Row = 1 To rows
        Dim a As String
        a = Cells(Row, 1).Value
        Windows("b.xls").Activate
        Sheets("sheet1").Activate
        Dim b As Long
        b = WorksheetFunction.Match(a, Range("a1:a28"))
        Dim c As Long
        c = Cells(b , 2).Value
        Windows("a.xls").Activate
        Sheets("file1").Activate
        Cells(Row, 2).Value = c
    Next Row
    End Sub
    Last edited by sha_ch; 06-21-2010 at 11:25 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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