Populate Cells on Main Sheet with Cells from Several Sheets

CathieGG

New Member
Joined
May 13, 2022
Messages
11
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Web
I have a workbook that tracks employee hours. I need to give the owner a breakdown/total of Vacation, PTO, Sick Time and Other for each employee on a bi-weekly basis.

I have currently been entering the cells from each workbook page individually, but there must be an easier way. Any help is appreciated. Thanks

Payroll.xlsx
ABCDEFGHI
1VacationSickPersonalTotalOther
2
31/15/22Jane Doe00000
41/29/22Jane Doe00008
52/12/22Jane Doe00000
62/26/22Jane Doe00008
73/12/22Jane Doe00000
83/26/22Jane Doe00000
94/9/22Jane Doe00000
104/23/22Jane Doe4000400
115/7/22Jane Doe00000
125/21/22Jane Doe00000
136/4/22Jane Doe00008
146/18/22Jane Doe00000
157/2/22Jane Doe80088
167/16/22Jane Doe80088
177/30/22Jane Doe00000
188/13/22Jane Doe00000
198/27/22Jane Doe00000
209/10/22Jane Doe0
219/24/22Jane Doe0
2210/8/22Jane Doe0
2310/22/22Jane Doe0
2411/5/22Jane Doe0
2511/19/22Jane Doe0
2612/3/22Jane Doe0
2712/17/22Jane Doe0
2812/31/22Jane Doe0
290
30
31Danielle Anderson56005640
YTD Calc
Cell Formulas
RangeFormula
C16:E16C16='Wk 07-16'!C27
C17:E17C17='Wk 07-30'!C27
C18:E18C18='Wk 08-13'!C26
C19:E19C19='Wk 8-27'!C25
I16I16='Wk 07-16'!F27
I17I17='Wk 07-30'!F27
I18I18='Wk 08-13'!F26
I19I19='Wk 8-27'!F25
A4:A28A4=A3+14
G3:G29G3=SUM(C3:E3)
I31,G31,C31:E31C31=SUM(C3:C30)
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi,

its a little tricky to understand your need without seeing an example of your employee sheets, and then also what you are trying to do with a "summary" sheet as such ?

Its not clear if this sheet you post is the summary, or an individual employee sheet (for Jane Doe) ?

It would be good to see your RAW data for each employee (examples of course) that you enter manually for your tracking purpose. Then let people here know what you want doing with it exactly ?
Great you were able to post the sheet though - just need to see a few more of your overal file please.

Also, if we could understand the structure of your workbook (in terms of sheets, how they are named, by employee, or by week number etc..)
cheers
Rob
 
Last edited:
Upvote 0
The sheet I am posting is the summary w/breakdown by pay period for each employee. Owner wants to see info without clicking every tab. So for Jane Doe I would import her cell values for Vacation, PTO, Sick Pay and Other from each tabbed location.

Here are the tab names
1662123939913.png


The info that I need to bring over to the main sheet is the same on each payroll tab.

Payroll.xlsx
ABCDEFG
23Payroll Ending 8/27/22
24RegularVacationSickPersonalOtherTotal
25Jane Doe80000080
26John Doe80000080
27Jane Smith80000080
28Joe Smith80000080
29Sam Smith72008080
30Tim Smith78.5000078.5
31Ed Smith62.50160078.5
32Mike Smith77.5001078.5
33Chris Smith80000080
34Chuck Smith72008080
35Sue Smith80000080
36Sue Doe80000080
37Ed Doe73.4207.757.75088.92
38Mike Doe72080080
39Kim Doe49.5000049.5
40Mark Doe45.5000045.5
411162.92031.7524.7501219.42
Wk 8-27
Cell Formulas
RangeFormula
B40:F40,B38:E39,C37:D37,B25:E36B25=B4+J4
F25:F39F25=F4+G4+N4+O4
G25:G40G25=SUM(B25:F25)
B37,E37B37=B16+J16+'Wk 09-10'!B16
B41:G41B41=SUM(B25:B40)
 
Upvote 0
Hi, thanks for the data. having your data stored on individual sheets is not so great for getting summaries.. as you can see :). So I tried to make it a little easier for you.

Create a New Sheet, called "YTD CALC" (note all capitals, not to overwrite your current "YTD Calc" sheet while you try it out.

On this sheet, you need to put your headings (C1 = "Regular", D1 = "Vacation", E1 = "Sick", F1 = "Personal", G1 = "Other", H1 = "Total") - note this is the same order as you have them on your bi-weekly sheets - very important. It's ok that they start in Col B in your bi-weekly sheets and in column C on "YTD CALC".

Instead of dates in your first column A, I have used the sheet name references as you have them, hoping thats ok - you'll see when you run it. The code also assumes that the data on each bi-weekly sheet starts at Row 25.


Then, you can insert this VBA code and run the macro. (Alt+F11 takes you to VBA editor, then just paste the code below to the into the blank box window on screen)

VBA Code:
Sub main()


Dim WS_Count As Integer
Dim I As Integer
Dim nrows, ytdlastrow As Long
Dim shtRange As Variant

WS_Count = ActiveWorkbook.Worksheets.Count
ytdlastrow = 1 'first row of data will be added to row 2
       
For I = 1 To WS_Count 'Loop through each worksheet

    If (ActiveWorkbook.Worksheets(I).Name <> "YTD CALC" And ActiveWorkbook.Worksheets(I).Name <> "YTD Calc") Then 'ignore the "YTC CALC" summary sheet
            sheetlastrow = ActiveWorkbook.Worksheets(I).Cells(Rows.Count, 1).End(xlUp).Row
          
            shtRange = ActiveWorkbook.Worksheets(I).Range("A25", "G" & sheetlastrow)
            nrows = sheetlastrow + 1 - 25 'how many rows of data were grabbed
             
            ActiveWorkbook.Worksheets("YTD CALC").Range("A" & ytdlastrow + 1, "A" & ytdlastrow + nrows) = ActiveWorkbook.Worksheets(I).Name
            ActiveWorkbook.Worksheets("YTD CALC").Range("B" & ytdlastrow + 1, "H" & ytdlastrow + nrows) = shtRange
          
            ytdlastrow = Sheets("YTD CALC").Cells(Rows.Count, 1).End(xlUp).Row 'reset last row on YTD CALC
      
    End If
Next I

End Sub

Hopefully having all your data at least stored on 1 page can now allow you to use filtering (Ctrl+Shft+L) on your table to just show whom you want, and from which week ?
Each time you run the macro, it will effectively overwrite the YTD CALC sheet each time with each sheet of data you have, and add the last one to the end.

Let me know if its helpful.

cheers
Rob
 
Last edited:
Upvote 0
Solution
Many thanks Cathie for the feedback. Glad to be of assistance.

Rob
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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