My Macro Isn't Working

Status
Not open for further replies.

shayalsamawi

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

Thanks so so much for helping me. I honestly love this site so much - it gives me wikipedia vibes (big fan).

My macro isn't working! Not sure what to do - super frustrating!

This is my sheet:

Book123.xlsm
ABCDEFGHIJKLMNOPQRS
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 the VBA code I'm using:

Sub shayalsamawi()
Dim Ary As Variant, Nary As Variant
Dim r As Long, c As Long, nr As Long

Ary = Sheets("Sheet1").Range("D6").CurrentRegion.Value2
ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 4)
For c = 3 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, 2)
Nary(nr, 4) = Ary(r, c)
End If
Next r
Next c
Sheets("Sheet2").Range("B2").Resize(nr, 4).Value = Nary
End Sub

This is what it's giving me:

Book123.xlsm
BCDE
2Sub LedgerProject DescriptionSubledger
3Sub LedgerIndirect TimeAdmin - Sales + MarketingSM
4Sub LedgerAdmin - Product SupportPS
5Sub LedgerAdmin - Applications SupportAS
6Sub LedgerAdmin - Customer SupportCS
7Sub LedgerCustomer Support (Help Desk)HD
8Sub LedgerAdmin - GeneralA
9Sub LedgerLeaveL
10Sub LedgerBank HolidayB
11Sub LedgerTrainingT
12Sub LedgerSickS
13Sub LedgerTime Off in LieuTOIL
14Sub LedgerOtherO
15Sub LedgerDevelopment ProgrammePRODUCT SUPPORT - Pulsar/Firebird052L2, 10
16Sub LedgerPRODUCT SUPPORT - Rockcore Product Support052L3, 10
17Sub LedgerPRODUCT SUPPORT - Overburden052L3, 20
18Sub LedgerPRODUCT SUPPORT - MQC052L1, 10
19Sub LedgerPRODUCT SUPPORT - CEM052L1, 20
20Sub LedgerPRODUCT SUPPORT - LEXMAR052L1, 30
21Sub LedgerPRODUCT SUPPORT - MQR052L4, 10
22Sub LedgerHypersense Product Support052L21, 10
23Sub LedgerProductionisation052L12, 130
24Sub Ledger90 80MHz Halbach052L13,10
Sheet2


This is what I want:

Book123.xlsm
MNO
22106324052L2, 106
23106324052L3, 105
246101274052L1, 208
Sheet2


So like, the person ID, the project they worked on and how many hours they did (avoiding any cells where there aren't hours in the timesheet). Could you please help me? Would massively appreciate it!! :)
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Duplicate to: Macro help?

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,934
Messages
6,175,488
Members
452,648
Latest member
Candace H

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