![]() |
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 -- 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 |
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 |
Macro/VBA help - lots of xls imports
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 th 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 DI myRange as range. put a button on the the spreadsheet use a normal drawing object. righ click on it and assign macro. I might catch up later to see how you got on regard -- tony ----------------------------------------------------------------------- tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107 View this thread: http://www.excelforum.com/showthread.php?threadid=52304 |
Macro/VBA help - lots of xls imports
Thanks to both of you - my spreadsheet is now up and running -- 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 |
All times are GMT +1. The time now is 12:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com