Extract 4 weeks data from a planning worksheet at increment of "1" in a cell for every worker and every task on each day

asla

New Member
Joined
Apr 12, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Web
I have a planning worksheet (sheet1) with number of vba codes (command buttons) that performs various task. I am now trying to add another function which is to extract and generate a 4 weeks summary (Sheet3) from sheet1 anytime the command button is clicked.

This is how the code on sheet3 will work:

  1. Extract all task (excluding workers column) from sheet1 and paste to sheet3
  2. Extract ONLY four weeks (from today) from sheet1 and paste it to sheet3.
  3. Extract weekdata (all "7.5") into sheet3 so that for every "7.5" it will be "1" in a single cell in a task row in sheet3. For example, if there are 3 men (rows) under a task (7.5 hours) on Monday, it should be "3" in a single cell corresponding to the day of the week in Sheet3. In other words, write the total number of men that work that day in Sheet3.
  4. Print sheet3 to PDF, etc.
The step I am having problem is the 3rd step. I have tried various ways to write the code section , but its not working, the closest one I did was this code below, (Note this is only working for one week, one task (Order 9427) as an example, I could not also figure how to adapt it to work for all the task and workers in sheet1). I attached the picture of the two sheets for clarification.


Dim totalMan As Integer


Set planWeek = Sheet1.Range("lw58:ma58")

For Each weekDay In planWeek


If Application.WorksheetFunction.CountA(weekDay) > 0 & weekDay = 1 Then

Sheet3.Range("d8").Value = 1
ElseIf Application.WorksheetFunction.CountA(weekDay) > 0 & weekDay = 2 Then

Sheet3.Range("d8").Offset(0, 1).Value = 1

ElseIf Application.WorksheetFunction.CountA(weekDay) > 0 & weekDay = 3 Then
Sheet3.Range("d8").Offset(0, 2).Value = 1
ElseIf Application.WorksheetFunction.CountA(weekDay) > 0 & weekDay = 4 Then
Sheet3.Range("d8").Offset(0, 3).Value = 1
ElseIf Application.WorksheetFunction.CountA(weekDay) > 0 & weekDay = 5 Then
Sheet3.Range("d8").Offset(0, 4).Value = 1


End If
Next
 

Attachments

  • sht1.PNG
    sht1.PNG
    147.7 KB · Views: 5
  • sht3.PNG
    sht3.PNG
    15.3 KB · Views: 5

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Extract 4 weeks data from a sheet at increment of "1" in a cell for every worker and task
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,773
Messages
6,126,817
Members
449,340
Latest member
hpm23

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