+ Reply to Thread
Results 1 to 4 of 4

Macro/VBA help - lots of xls imports

  1. #1
    Registered User
    Join Date
    03-16-2006
    Posts
    12

    Macro/VBA help - lots of xls imports

    I have 3 spreadsheets A, B and C

    A & B contain information in the exact same format

    With C I have 2 columns that compare their values against each other and highlight any differences(through a small VBA script)

    I want 2 buttons in C spreadsheet that:

    Button 1: Offers the user to open a spreadsheet(A - name can vary) then copies A2:A500 of that spreadsheet to spreadsheet C(A2:A500)

    Button 2: Offers the user to open a spreadsheet(B - name can vary) then copies B2:B500 of that spreadsheet to spreadsheet C(B2:B500)

    Any ideas if this is possible

  2. #2
    Tom Ogilvy
    Guest

    RE: Macro/VBA help - lots of xls imports

    Sub GetfromA()
    Dim fName as Variant
    Dim bk as Workbook, sh as Worksheet
    set sh = Activesheet
    fname = Application.GetOpenfilename("Excel Files (*.xls),*.xls")
    if fName = False then exit sub
    set bk = Workbooks.Open(fName)
    bk.Worksheets(1).Range("A2:A500").copy _
    Destination:=sh.Range("A2")
    bk.close SaveChanges:=False
    End Sub


    Sub GetfromB()
    Dim fName as Variant
    Dim bk as Workbook, sh as Worksheet
    set sh = Activesheet
    fname = Application.GetOpenfilename("Excel Files (*.xls),*.xls")
    if fName = False then exit sub
    set bk = Workbooks.Open(fName)
    bk.Worksheets(1).Range("B2:B500").copy _
    Destination:=sh.Range("B2")
    bk.close SaveChanges:=False
    End Sub

    --
    Regards,
    Tom Ogilvy



    "Steve M" wrote:

    >
    > I have 3 spreadsheets A, B and C
    >
    > A & B contain information in the exact same format
    >
    > With C I have 2 columns that compare their values against each other
    > and highlight any differences(through a small VBA script)
    >
    > I want 2 buttons in C spreadsheet that:
    >
    > Button 1: Offers the user to open a spreadsheet(A - name can vary) then
    > copies A2:A500 of that spreadsheet to spreadsheet C(A2:A500)
    >
    > Button 2: Offers the user to open a spreadsheet(B - name can vary) then
    > copies B2:B500 of that spreadsheet to spreadsheet C(B2:B500)
    >
    > Any ideas if this is possible
    >
    >
    > --
    > Steve M
    > ------------------------------------------------------------------------
    > Steve M's Profile: http://www.excelforum.com/member.php...o&userid=32520
    > View this thread: http://www.excelforum.com/showthread...hreadid=523047
    >
    >


  3. #3
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187
    I will point you in the right direction as I am just off to a meeting.

    use tools record macro and then carry out the open and copy stop the macro and have a look at the code. Expect to replace the "selection" object with a range object which you will need to declare eg DIM myRange as range.

    put a button on the the spreadsheet use a normal drawing object. right click on it and assign macro.

    I might catch up later to see how you got on

    regards

  4. #4
    Registered User
    Join Date
    03-16-2006
    Posts
    12
    Thanks to both of you - my spreadsheet is now up and running

+ 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