Import data from one spreadsheet to another using a button

heather_1983

New Member
Joined
Aug 27, 2011
Messages
1
Hi

I want to put some code behind a button that when pressed will copy the rows that i have highlighted and transfer them into a new worksheet.

The spreadsheet I have set up will calculate the average hours worked using start and finish times. I just need to work out how to import data from a report which is generated by a bespoke system and put the data into another worksheet.

I am self taught, so could any explanations be idiot proof? lol

Thanks in advance.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hiya - welcome to the forum!

If you attach the following to a button - adding a few tweaks - it should do it.

The code opens a target file, and copies a fixed row to a row in your application. Hope that helps.

Code:
Dim sApp As String
Dim sTarget As String
sApp = ActiveWorkbook.Name
Workbooks.Open Filename:="C/...."
sTarget = ActiveWorkbook.Name
Workbooks(sApp).Sheets(1).Range("C:D").Value = Workbooks(sTarget).Sheets(1).Range("C:D").Value
Workbooks(sTarget).Close
Workbooks(sApp).Activate

D
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,328
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top