Formula or macro?

gd6noob

Board Regular
Joined
Oct 20, 2017
Messages
170
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a workbook with 5 sheets.
Sheet 1 is the main page where all the data will be compiled and should not be touched.

Sheet 2-5 will be worked on by 4 different people.
Whats the best way to have all the data being showed on the main page without having to copy/paste every time all the information or from accidentally being deleted?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Sorry, I think I wasnt clear in my first post.

I want Sheet 1 to have all the data from Sheet 2-5.
 
Upvote 0
more information will probably be required before anyone can start to help you:
do the other 4 people have their own sheet? or do they all use sheets 2-5?
how much information will they be entering? i.e. 1 row only or the same number of rows each? different amounts of input?
Is their input cleared every time after it is transferred to sheet1?
are all the sheets formatted the same way?
I could imagine using a macro/button on each sheet to cut/copy data from sheet then transferring it to the next empty row on sheet 1.
 
Last edited:
Upvote 0
Thank you for the quick reply.

Each person will have their own sheet to work on.
Rows will be different for each person, same with the values in each cell
Columns will be standard across all sheets.

The button option sounds like it would work and easier to execute for the user.
 
Upvote 0
gd6noob,
I created three macros which can be made to operate with form control buttons (see below for instructions).
Following Logit's suggestion to hide sheet 1 and make it visible using a password requires the first two macros.
It is logical to hide sheet1 again after viewing... that requires a 3rd button which would go on sheet 1.

You have not furnished the following information:
1 - How many (maximum number of) columns on each of sheets 2 - 5?
2 - Are the column headers all in one row, or multiple rows? In what row/cell does the actual data begin...A2?
3 - Is there one column that will always have data down to the last row? Column A?
3 - On sheets 2 - 5...'Is the input cleared (from each sheet) every time after it is transferred to sheet1?' (Requested by keithmct in post #4 )

So, I made the noted assumptions in the macros below. You can run them on a copy of your workbook using Alt_F11 to open the Visual Basic Editor, then paste a copy of the 3 macros into the large window that opens, close the Editor window, and SaveAs macro enabled (*.xlsm).

To run the macros go to one of the sheets 2 to 5, Press Alt+F8, then select 'AddTOSheetOne', then 'Run'. Sheet1 will become hidden.

To see sheet1 again, Press Alt+F8, then select 'ViewSheetOneWithPW' then 'Run'. You will be asked for the password...enter 'mypassword' without the single quotes, then press 'OK'.
To hide sheet1 again either run 'AddTOSheetOne' again from another sheet, OR run 'HideSheetOne'.
I have included instructions on how to install a Form Control Button below the macros.
Perpa

Code:
Sub AddTOSheetOne()
Dim LastCol, LastRow As Long
Dim wsStart As Worksheet
Set wsStart = ActiveSheet
   With ActiveSheet
        LastRow = .Cells(Rows.Count, "A").End(xlUp).Row                   'Assumes column A will always have data to the last row - Change to suit
        LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column     'Assumes row 1 is the header row for ALL columns - Change to suit
        Set Rng = .Range(Cells(2, 1), Cells(LastRow, LastCol))              'Assumes cell A2 is first cell with data - Change to suit
        Rng.Select
        Rng.Copy ThisWorkbook.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End With
    
'wsStart.Rng.ClearContents               'Commented out to keep contents on sheets 2-5, remove single quote preceeding 'wsStart if they should be cleared
 wsStart.Range("A2").Select              'Unselects copied range and puts cursor in cell A2
 ThisWorkbook.Sheets("Sheet1").Visible = xlSheetHidden
End Sub

Sub ViewSheetOneWithPW()
Dim pw As String
    pw = InputBox(prompt:="Enter Password to Copy Your Sheet to Sheet1")
    
    If pw = "mypassword" Then     'Change 'mypassword' to your password - put in double quotes
       ThisWorkbook.Sheets("Sheet1").Visible = xlSheetVisible
    End If
End Sub

Sub HideSheetOne()
 ThisWorkbook.Sheets("Sheet1").Visible = xlSheetHidden
End Sub
To add a Form Control Button to an Excel Worksheet:
You need the Developer Tab in the ribbon at the top of the sheet activated to do this. If you need this installed...
1st - Click on the Windows icon, the 4 colored boxes in the circle at the top lefthand of the screen, next to 'Home'. At the bottom of that tab click on 'Excel Options', then click on the 'Popular', then 'Show Developer tab in the Ribbon'. Then click 'OK' at the bottom of that tab. You will notice that the 'Developer' tab has been added to the ribbon. Now save your workbook.

2nd - Select the sheet where the button will go. Left click on the Developer tab. In the middle of that tab is an icon labled 'Insert'. Click on that icon and you will see 2 sets of controls, you want the 'Form Control' group, hover the cursor over the icon that looks like a rectangular button. It should say 'Button - (Form Control)'. Click on that icon, then down where you want the top LH corner to be, left click, hold and drag down to where you want the lower RH corner. The button is labled 'Button 1' by default. You can change that later, but first you should be promted to select a macro to assign to the button. Select 'AddTOSheetOne' from 'This Workbook'. You can now right click on the 'Button 1' name and you can change that to 'Copy to Sheet 1' or whatever. Then click outside the button and save your workbook again. You are now ready to use the button. Repeat to create a second button for 'ViewSheetOneWithPW'. You will need to do this for sheets 2 to 5.
Put a similar button on Sheet1 for the 'HideSheetOne' macro. Obviously, Sheet1 does not use the other 2 buttons.
 
Upvote 0
Hi Guys..

Sorry for the late reply.

For this spreadsheet, Sheets 2-5 will be edited by 4 individuals. Column A is missing but its there.
The number of rows will vary by the individuals but the columns will be the same.
7B7EoU2.jpg




For this spreadsheet, I was thinking of a button with a script to copy/refresh any updates on sheet 2-5 to reflect on sheet 1, somewhere in column G. Or maybe it would be easier without a button?
The end goal for this is whatever information is added/edited on sheets 2-5, will reflect on sheet 1, so not sure if a button is the way to go or have it updated realtime.
Fjg6Cl9.jpg



Thank you in advanced
 
Last edited:
Upvote 0
I'm assuming you want the input in sheets 2-5 to stay there as a "running" record for each employee and have sheet 1 as a master running record for all employees. I don't know how to get excel to select only the new data you want to transfer, other than have, for each employee, an input sheet which you can get excel to select all data from a certain row down, copy and paste it to the master sheet and also paste it to a new sheet for that employee as a running record. I tried to get this to work but it pastes the data in funny places. Maybe someone else could get my code to work?
Code:
Private Sub CommandButton1_Click()
    
    Dim rng As Range
    Set rng = ActiveSheet.UsedRange
    Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)
    rng.Select
    
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet1").Select
        Destination = Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    ActiveSheet.Paste
    
    Sheets("Sheet3").Select
        Destination = Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    ActiveSheet.Paste
    Sheets("Sheet2").Select
    Range("A2:I100").ClearContents
End Sub
 
Last edited:
Upvote 0
Thanks for the help.
So lets say I on sheet 1, row 12 has the values of this person and then columns D through I, values are changed in either sheets 2-5, I would like the those values to be updated on sheet 1.
And if on sheet 2-5, the entry of a person is now deleted and not on the list, I would like the entry on sheet 1 to be removed as well... So sheet 1 will always have the updated values from sheet 2-5.

Also, is it possible to stop people from editing sheet 1 but can still copy the info?

Is this possible to do in excel?
 
Last edited:
Upvote 0
gd6noob,
Thank you for posting a screenshot of sheet1 and a sample of sheets 2 to 5...that helps a lot.
On sheets 2 to 5:
Column A is the 'Employee ID' which I assume would be entered once for each sheet. Row 2 would make sense so when copied to sheet 1 that could be the 'separator' from one employee to the next. You may want an additional blank row on sheet 1 between the last entry and the newly copied data.

Per your latest post (9) - whenever there is a change on anyone of sheets 2 to 5, you want only the current data from sheets 2, 3, 4, and 5 to be shown on sheet1. With that in mind, the best solution would be to refresh sheet 1 so it is reflective of the other sheets when the button on any sheet is pressed. That button would clear sheet1, and then copy what is currently on the other 4 sheets onto sheet1. Sheet1 would be hidden to prevent anyone using sheets 2 to 5 from making changes directly to Sheet1, unless they have the password.
So the last person entering data by pressing the button on their sheet will clear sheet1 and copy all 4 current sheets to Sheet1.

I'm unclear what you mean in your last sentence '... is it possible to stop people from editing sheet 1 but can still copy the info?"
Do you want each person to be able to copy all the data from the other sheets to another workbook, or do you want to copy all the data to a 'Sheet6' so they can view the information on all the sheets all together? Sheet6 would be a copy of Sheet1. Please clarify.

Does this sound like we are getting to the solution you are looking for?
I have a meeting tonight, and I volunteer tomorrow morning, so I probably won't be able to see your return comments until tomorrow afternoon.
But I will check back.
Perpa
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

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