da_reynolds
New Member
- Joined
- Jun 27, 2011
- Messages
- 3
Hey All,
First post on the forum, usually find what I want in other peoples questions, hope you can help me out.
I have a list of times which need to be entered into a sheet for each contractor against the work they have done. Originally I used a sum product to pull the value out based on 2 unique codes, one for the time and shift, and one for the contractor and work. However, with over 180000 cells this takes for ever. I was hoping to replace it using the find function to search for one unique code, return the associated row, and the other for the column, then put the value into my list into this matrix.
Diagramatically:
A|F|50hr
B|G|40hr
C|H|10hr
D|I|5hr
E|J|3hr
into
....A...B...C...D...E
F..50.................
G .....40.............
H ..........10........
I ................5....
J ....................3
This is simplistic, it won't be a diagonal matrix of values.
I can't get the code i've written to work properly, any help would be greatly appreciated.
Thanks!
First post on the forum, usually find what I want in other peoples questions, hope you can help me out.
I have a list of times which need to be entered into a sheet for each contractor against the work they have done. Originally I used a sum product to pull the value out based on 2 unique codes, one for the time and shift, and one for the contractor and work. However, with over 180000 cells this takes for ever. I was hoping to replace it using the find function to search for one unique code, return the associated row, and the other for the column, then put the value into my list into this matrix.
Diagramatically:
A|F|50hr
B|G|40hr
C|H|10hr
D|I|5hr
E|J|3hr
into
....A...B...C...D...E
F..50.................
G .....40.............
H ..........10........
I ................5....
J ....................3
This is simplistic, it won't be a diagonal matrix of values.
I can't get the code i've written to work properly, any help would be greatly appreciated.
Code:
Sub Populate_sheet()
Dim SearchCell As Range
Dim FoundCell1 As Range
Dim FoundCell2 As Range
Dim SearchRange1 As Range
Dim SearchRange2 As Range
Dim i As Integer
Dim y As Integer
Dim x As Integer
i = 1
Set SearchRange1 = Worksheets("Timesheet").Range("M3:DA3")
Set SearchRange2 = Worksheets("Timesheet").Range("A7:A3000")
For Each cell In Worksheets("Calcs").Range("I3:I30")
Set SearchCell = Worksheets("Calcs").Cells(i, 1)
Set FoundCell1 = SearchRange1.Find(SearchCell, LookIn:=xlValues)
y = FoundCell1.Column
Set SearchCell = Worksheets("Calcs").Cells(i, 2)
Set FoundCell2 = SearchRange2.Find(SearchCell, LookIn:=xlValues)
x = FoundCell2.Row
Worksheets("Calcs").Cells(i, 9).Value = Worksheets("Timesheet").Cells(x, y)
i = i + 1
Next
End Sub
Thanks!