2
votes

I am trying to move data from one workbook 'input worksheet' to another workbook 'master workbook'. Both sheets are in the same file and if possible, it would be great if both files didn't have to be open at the same time in order to transfer the data but the master workbook would autosave once the data was transferred across. Links to images of the files below to make it easier to understand what I am trying to do.

The data in the input worksheet is in row 6, columns A-J with each user inputting details of the tasks they get asked to complete. I would like when a button is clicked, the data from the input worksheet is transferred into row 2, columns B-K in the master workbook so that each time a new task is entered and transferred across, it appears in the row below (so that it can be pivoted later, etc.).

http://i.stack.imgur.com/b2cyI.jpg - input sheet

http://i.stack.imgur.com/JZr0a.jpg - master sheet

1
If you have tried anything, post the code pleasegizlmo

1 Answers

1
votes
  1. Use the macros here to get the last row in the master sheet.
  2. Then simply write the values from the input sheet to the corresponding cell in the master sheet.
  3. That is all. This is how you refer cells:

    tbl_master.cells(1,3) = tbl_input.cells(3,5).value

Make sure that the row in the tbl_input is a variable, coming from the function, calculating the last row. Give it a try!

Edit: This is what I use for last row:

Public Function last_row_with_data(ByVal lng_column_number As Long, shCurrent As Variant) As Long

    last_row_with_data = shCurrent.Cells(Rows.Count, lng_column_number).End(xlUp).Row

End Function

If you want to find the last row of column B of sheet "tbl_main" you call it like this:

last_row_with_data(2,tbl_main)

Edit2: Change the names of your sheets here, and reference them by their names. enter image description here

In order to get this window, select the sheet on the left and press F4.