Macro help?

shayalsamawi

New Member
Joined
Sep 9, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hi All,

This is my first post - thanks so much in advance for helping.

I have data that looks like this:

ProjectSubprojectSamTomTerryAlice
Project 1Subproject b
4​
1​
6​
Project 2subproject d
5​
4​
5​
Project 3subproject f
3​
3​
6​
Project 4subproject q
4​

It's a time sheet with names of individuals and how many hours they spent on each task.

I need it to look like this:

samproject 1subproject b
4​
samproject 3subproject f
3​
TomProject 2Subproject d
5​

so - removing any cells with no hours, the data is almost transposed with the name, project, subproject and hours.

I have to do this sheet weekly, which is why I wanted a macro to hopefully speed the process up.

I'd massively massively appreciate any help

Thanks
Shay
 
Hi Fluff,

I didn't mean to - I really thought the concept was similar enough,I didn't know about the XL2BB at the time of posting...it's okay - i will find a solution elsewhere.

For info - output P was just an example of hours - they aren't on data - I just wanted to show what I'd want it to look like once the timesheet is populated.

I apologise for wasting your time - I had no intention of this.

Thanks again anyway

Shay
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You do not need need to look elsewhere, but before I write the new code I would like to see exactly what you are after from the data you showed, otherwise I'm just guessing.
 
Upvote 0
You do not need need to look elsewhere, but before I write the new code I would like to see exactly what you are after from the data you showed, otherwise I'm just guessing.
Hi Fluff,

Thanks again for your help.

I hope this is clear - I've tried to make it as clear as possible (as I should have in the beginning).

This is my whole spreadsheet:

Book1
ABCDEFGHIJKLMNOPQRS
1
2Week Ending12/09/2021
3
4Project DescriptionSub LedgerUncompleted HoursUncompleted HoursUncompleted HoursFinished HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted HoursUncompleted Hours
5Person 1Person 2Person 3Person 4Person 5Person 6Person 7Person 8Person 9Person 10Person 11Person 12Person 13Person 14Person 15Person 16
6Project DescriptionSubledger106324610127410632110655317113425288861006501195261418166101053273969163932610122461005376101203106313
7Indirect TimeAdmin - Sales + MarketingSM
8Admin - Product SupportPS
9Admin - Applications SupportAS
10Admin - Customer SupportCS
11Customer Support (Help Desk)HD
12Admin - GeneralA23
13LeaveL
14Bank HolidayB
15TrainingT
16SickS1
17Time Off in LieuTOIL
18OtherO
19Development ProgrammePRODUCT SUPPORT - Pulsar/Firebird052L2, 10
20PRODUCT SUPPORT - Rockcore Product Support052L3, 103437
21PRODUCT SUPPORT - Overburden052L3, 20
22PRODUCT SUPPORT - MQC052L1, 10
23PRODUCT SUPPORT - CEM052L1, 20
24PRODUCT SUPPORT - LEXMAR052L1, 30
25PRODUCT SUPPORT - MQR052L4, 102
26Hypersense Product Support052L21, 102
27Productionisation052L12, 130
2890 80MHz Halbach052L13,10
29Overburden Mk2052L20, 10
30MQC-R052L26, 10
31Q-Sense MQC052L27, 10
32Automation for X-Pulse052L28, 10
33AZUL052L14, 10
34BLOC - Work Package 1052L24,10
35BLOC - Work Package 2052L24,20
36BLOC - Work Package 3052L24,30
37BLOC - Work Package 4052L24,40
38BLOC - Work Package 5052L24,50
39BLOC - Work Package 6052L24,60
40Spinflow V3.1052L29, 10
41External lock for X-Pulse052L30, 10
42Switched Probe X-Pulse052L38, 10
43X-Pulse 80/Cost Down052L31, 10
44Halbach 20052L32, 10
45MQC HT052L33, 10
46Spin Studio Application Releases - Toothpaste052L34, 10
47Spin Echo (Grant)052L35, 10
48X-Pulse Probe052L38, 10
49Nottingham Trent University052L37, 10
50Project Build TimeVDvG052J926
51Copenhagen052J777
52Dupont Autosampler052J2750
53InstallationsMQR20-IFPEN, France052X002
54Geospec 12-50 and 2-100 - SONATRACH052X013
55Geospec 12-50 and 2-75 - KAUST052X218
56Munich PM visit052X902
57ESSO MQC to MQC+ upgrade052X898
58X-Pulse installation at Heriot-Watt University - 052S573 - 4 days on site052X945
59DuPont MQC+ MQ-Auto Installation (preparation)052X784
60University of Oxford glove box move (initial survey)052X981
61Installation and training at CBRN Romania 052S650052X973
62Lulea University of Technology Sweden (052S789)052X1018
63ServiceFOC Customer Support
64Support ContractsSUPP
65Munster University Pulsar Repair and Upgrade to Win 10
66Repair to PUL1026 - Germany (Rototec-Spintec)052X890
67Holme House Repair Visit052X1022
68ONGC CEWELL remote PM052X984
69Minakem Pulsar Assessment + Repair052X1021
70Toulouse Upgrade and Repair052L36, 10
71United Utilities MQC+ Autosampler PM052X1033
72Koura Global (Mexichem) PM052X1039
Sheet1
Cell Formulas
RangeFormula
D4:S4D4=IF(SUM(D7:D94)>36.99,"Finished Hours","Uncompleted Hours")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D4:S4Cell Valuecontains "Finished Hours"textNO
D4:S4Cell Valuecontains "Uncompleted Hours"textNO
D6:S6Cell Valuecontains "Finished Hours"textNO
I12Cell Valuecontains "Finished"textNO
D6:S6Cell Valuecontains "Uncompleted Hours"textNO
D7Cell Valuecontains ""Uncompleted Hours""textNO


This is a zoom in of the first section as an example of what I mean:

Book1
CDEFGH
6Subledger1063246101274106321106553171134
7SM
8PS
9AS
10CS
11HD
12A
13L
14B
15T
16S1
17TOIL
18O
19052L2, 10
20052L3, 103437
21052L3, 20
22052L1, 10
23052L1, 20
24052L1, 30
25052L4, 102
26052L21, 10
27052L12, 130
28052L13,10
29052L20, 10
30052L26, 10
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:S6Cell Valuecontains "Finished Hours"textNO
D6:S6Cell Valuecontains "Uncompleted Hours"textNO
D7Cell Valuecontains ""Uncompleted Hours""textNO


I would like the data to look like this, leaving out where there is 0 hours worked on a project.

Book1
LMN
7106324052L4, 102
86101274052L3, 103
9106321052L3, 104
10106553052L3, 1037
Sheet2


So - showing, the person ID, the subledger code and the hours worked on that specific project.

I hope this is clear.

Thanks again
 
Upvote 0
Thanks for that, are you only interested in the hours worked from row 19 down, or do you also want the hours from rows 7 to 18?
 
Upvote 0
No - apologies - this was only for an example. I'd like them all, spanning all 16 employees (column D to S) and all projects (row 7 to row 72)
 
Upvote 0
Ok, how about
VBA Code:
Sub shayalsamawi()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nr As Long
   
   With Sheets("Sheet1")
      Ary = .Range("C6:S" & .Range("C" & Rows.Count).End(xlUp).Row).Value2
   End With
   ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 3)
   For c = 2 To UBound(Ary, 2)
      For r = 2 To UBound(Ary)
         If Ary(r, c) <> "" Then
            nr = nr + 1
            Nary(nr, 1) = Ary(1, c)
            Nary(nr, 2) = Ary(r, 1)
            Nary(nr, 3) = Ary(r, c)
         End If
      Next r
   Next c
   Sheets("Sheet2").Range("A2").Resize(nr, 3).Value = Nary
End Sub
 
Upvote 0
Solution
Thanks for that, are you only interested in the hours worked from row 19 down, or do you also want the hours from rows 7 to

Ok, how about
VBA Code:
Sub shayalsamawi()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nr As Long
  
   With Sheets("Sheet1")
      Ary = .Range("C6:S" & .Range("C" & Rows.Count).End(xlUp).Row).Value2
   End With
   ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 3)
   For c = 2 To UBound(Ary, 2)
      For r = 2 To UBound(Ary)
         If Ary(r, c) <> "" Then
            nr = nr + 1
            Nary(nr, 1) = Ary(1, c)
            Nary(nr, 2) = Ary(r, 1)
            Nary(nr, 3) = Ary(r, c)
         End If
      Next r
   Next c
   Sheets("Sheet2").Range("A2").Resize(nr, 3).Value = Nary
End Sub
Thank you so so much - this is exactly what I was after, works perfectly. Thanks so much
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,935
Messages
6,175,495
Members
452,649
Latest member
mr_bhavesh

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