Running Sum through Range then Output Results to another Sheet - VBA

oasisdec

New Member
Joined
Oct 4, 2017
Messages
3
Thank you in advance for taking a look at this project. I am proficient in normal excel functions but am fairly new to writing VBA code and am completely lost with how to start with this project. I have tried several approaches all to no avail and now have no choice but to ask for help.

My end goal is to create a separate sheet with records that displays data extracted from another sheet.

The code will need to essentially record the start date/time of a down-shift and sum up the hours of consecutive down shifts where a shift is 8 hours.

Below is the format of the data that needs to be extracted. "X"s and "W"s represent up-shifts whereas "H" and blank cells represent down-shifts. Additionally "1/2" means half-shift. Every column represents a day and the rows represent the three shifts for each day.

Starting in cell E5, the code needs to iterate through the full range of each table by first going down three rows and then over to the next column to the right, etc.; all the way to the end of the table which is column "IV".

After that it will need to start over again for the next table, E12. There are multiple tables on the sheet that the code will have to iterate through in order to complete the project. These tables all share the same columns, are all formatted the same and are the same dimensions.

QKovCdZjBSoOY5GGMhuL5jlcANqmQtKdYIwcFySlS9H5hY16NyOKrhGh4xjIUzaSWKG2WFN7GasjwiLxlhzS5R8UMBA-HOL2u4SGf_9EiMxjOsOJTqzsQqp4JvhmAvojSkpDhAs4Q0jZUDNkYlNceMdKdGomc9b_52ty_8SjbBwzE43tWvOLwPvYfkmwO1-KxuOA5gYfWVsqc_KjWjJS7zDc4kssauiM_iWxsnYE273KZ40_3g5IgRhUyWXJ_Z1AmnzNO2DtAhel6xUJ3WQ534eP2jY_BjLcc3kL2CZ8rUgxVmnWDX8AbHb-mmRB1a-KG8R-YfBwj5WMF6-JJbnU3xSgR7PgAS2qsYldaiqreUu6mdH2xxBNKcZdkMrnET1LDN3zj9fsKl6AXnQ_6KotXZLZS-oMnF5aWIBNbPHL6AgsVhkxJmbu4ecOA5xjTQgTc4_xpNuU0l2UMgWInoiJzV1bJkd2sszF1wk8swFVSbQa6zc1MMAIGY_jsOlgXS0cEqrjTLhc8XfTWpFiJZjdjkvQSf87TDAXpmH80uXPuZrustCiBqdZ_zyPWjBFaapHxLA17N0_60mWRknf5mm41LVNRZSEM7FIC4uUiqLSdQ=w649-h311-no



The results need to be in the below format on a newly created sheet in the same workbook.

Each record shows the department (column A in the original sheet), date/time that the down shift started and for how long (hours) it was down for.

GNUlrToOkPOe6cReXDqSCa-NJdJ0N4fLovn-8Wh8w_B-ew1ACuMfpN22yTnIbKHVj7AfbPYdWwgckBNDaxjMg8f2JxwuXJPfiOy7EvnWnJiuG3XYy0P8R4rm46ZUZCYXZ_PpUY3OMuDcjcigpinSJcxKz9Wny6woZfHv1Jb3VDk-veyMelvVSGUzq2aa8DHOlBWeXaVSqX_dXU8ogRTa3byLipH6uZQoM_WVmRaz7sKl-spUjCnhDHcEM_pCVr6J3ebwyl49LspVkSIm9f0rdTiczzuf9nh4_HAlP7zkLiHY2zvmA3fUDVhKSwtI6MBdiWKhUSVOpuNUSvfHyouCiTX-8TmCCuKnrLpC93Ssukk7OWnZWHF7WSToNwHNjSyHEg7iPgtlQek-4R2z8OgADiiuBqgy7w6WJ89smAzMsuPd23NYnGF00WbOY0s0W-OwYKHX3IGV3fUPhmRE9YlxCdzrg-cM_jMcI3cRxAphIJxeWWh8sdDZ-vpDSjO-uWWi3jYtg0ZhR-omHMY9WyRIDP_RsH2IJWiL9aM2yWTwdmqvDQpEuN-jY6morhuJ7xsiGFzEtbPEQacsiHRrKtRCkn_Kfehf7OTvqOsO59simg=w296-h357-no



Things to note:

- Dates are in the rows right above each table. They are formatted to only show the day.
- The start time for the first row in each table is from the day before. For example: the down shift that starts on cell F5 actually starts at 11:00 PM on the 20th.
- Column C is start time of shift and Column D is the end time.
- There are other shift indicators such as "R", "J", "1/4" and "3/4". I would like to be able to add new/revise existing indicators and their values to the code.
- For partial shifts (ie "1/2"), the downtime always start at the beginning of the shift.

Thank you again for your help and time!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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