Problem with collecting data into array with input

elefantsko

New Member
Joined
Feb 18, 2015
Messages
3
Hi everyone! I have a small problem and I really can't figure out how to solve it.
I have a sheet called "TIDRAPPORT" where i have lots of rows with lots of info. You can say it's a "time report excel document" for a company. What I want to do is calculate the amount of time each person has worked in a specific project. I'll post a picture of one of the rows:
7RJN2EW.png


Column C is the Order nr that the user write in a textbox and clicks "go". What my program should do then is go through all rows and collect the workers (column I, "Vem") and the time they work (Kolumn J, "Tid"). If the name occurs twice or more the program will then add the ours to the person with the same name.

I have managed to write the code (which I also got help with) to collect the hours workers worked, but in ALL PROJECTS (there are alot).. I'm having trouble with writing the code so it checks that the input is the same as the content in column C before it adds the information to the array.. Can somebody help?


Ps. I'm sorry but I don't know how to write the code in "code mode".. But here's what i got so far:


Sub getWorkers()
Dim s As String
s = Worksheets("PROGRAM").TextBox1.Text


Dim Dic As Object, oCell As Range, i&, y%, key As Variant
Set Dic = CreateObject("Scripting.Dictionary")
y = 1: i = ThisWorkbook.Sheets("TIDRAPPORT").Cells(Rows.Count, 9).End(xlUp).Row

For Each oCell In Range("I26:I" & i)

If Not Dic.exists(oCell.Value) Then
Dic.Add oCell.Value, WorksheetFunction.SumIf(Range("I26:I" & i), oCell.Value, Range("J26:J" & i))
End If
Next


For Each key In Dic
Debug.Print key, Dic(key)
Next

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi everyone! I have a small problem and I really can't figure out how to solve it.
I have a sheet called "TIDRAPPORT" where i have lots of rows with lots of info. You can say it's a "time report excel document" for a company. What I want to do is calculate the amount of time each person has worked in a specific project. I'll post a picture of one of the rows:
7RJN2EW.png


Column C is the Order nr that the user write in a textbox and clicks "go". What my program should do then is go through all rows and collect the workers (column I, "Vem") and the time they work (Kolumn J, "Tid"). If the name occurs twice or more the program will then add the ours to the person with the same name.

I have managed to write the code (which I also got help with) to collect the hours workers worked, but in ALL PROJECTS (there are alot).. I'm having trouble with writing the code so it checks that the input is the same as the content in column C before it adds the information to the array.. Can somebody help?


Ps. I'm sorry but I don't know how to write the code in "code mode".. But here's what i got so far:


Sub getWorkers()
Dim s As String
s = Worksheets("PROGRAM").TextBox1.Text


Dim Dic As Object, oCell As Range, i&, y%, key As Variant
Set Dic = CreateObject("Scripting.Dictionary")
y = 1: i = ThisWorkbook.Sheets("TIDRAPPORT").Cells(Rows.Count, 9).End(xlUp).Row

For Each oCell In Range("I26:I" & i)

If Not Dic.exists(oCell.Value) Then
Dic.Add oCell.Value, WorksheetFunction.SumIf(Range("I26:I" & i), oCell.Value, Range("J26:J" & i))
End If
Next


For Each key In Dic
Debug.Print key, Dic(key)
Next

End Sub

Have you considered just making a Pivot Report for this?
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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