Vba - multivlookup

Nunos11

New Member
Joined
Jul 25, 2014
Messages
9
Hello everybody,

I block with loop.

I try to consolidate table with 3 criteria. In first time I look to find item in accordance with another value. And second time to search in accordance with the first action the value stack in table PROD.

I attach the file, it's more explicit .....

File

Current script:

Code:
Option Explicit
Sub TaskperDay()
'--------------------------------------------------------------------------------------------------------------------------
'Variable
'--------------------------------------------------------------------------------------------------------------------------
    Dim cellule As Range 'variable range
    Dim value1 As Range 'variable text
    Dim l As Long, Li As Long, C As Long
    Dim Cel As Range, Cel1 As Range
    Dim derligne As Integer
    Dim i As Byte, x
    'Sheets("Matrice").Range("BJ2:BT" & Sheets("Matrice").Range("BJ65535").End(xlUp).Row).ClearContents 'ajout
'--------------------------------------------------------------------------------------------------------------------------
'MSN link to SCOPE
'--------------------------------------------------------------------------------------------------------------------------
  'Source value
  Set value1 = Sheets("Dashboard").Range("A2")
  'Search the value in extract tab
  For Each cellule In Sheets("Table").Range("Q2:Q" & Sheets("Table").Range("A65535").End(xlUp).Row)
  If cellule = value1 Then
  'Write the resultat
  Sheets("Matrice").Range("BJ" & Sheets("Matrice").Range("BJ65535").End(xlUp).Row + 1) = Sheets("Table").Cells(cellule.Row, 1)
  End If
  Next
'--------------------------------------------------------------------------------------------------------------------------
'Consolidation Hours
'-------------------------------------------------------------------------------------------------------------------------
derligne = Sheets("PROD").Cells(65000, 1).End(xlUp).Row
Li = 2
For i = 1 To derligne Step 11


    If IsDate(Sheets("PROD").Cells(i, 2)) Then
        For Each Cel In Sheets("PROD").Range("A" & i & ":Q" & i)
            If Cel = Sheets("Matrice").Range("BJ1") Then C = Cel.Column: Exit For
        Next
        If C > 0 Then
            For Each Cel1 In Sheets("Matrice").Range("BK1:BT1")
                For Each Cel In Sheets("PROD").Range("A" & i + 1 & ":A" & i + 10)
                    If Left(Cel, Len(Cel1)) = Cel1 Then l = Cel.Row: Exit For
                Next
                Sheets("Matrice").Cells(Li, Cel1.Column) = CDate(Sheets("PROD").Cells(l, C))
                Sheets("Matrice").Cells(Li, Cel1.Column).NumberFormat = "0.0"
            Next
        End If
    End If


Li = Li + 1
If Sheets("Matrice").Range("BJ" & Li) = "" Then Exit For
Next i
'--------------------------------------------------------------------------------------------------------------------------
'Clear memory system
'--------------------------------------------------------------------------------------------------------------------------
  Set Cel = Nothing
  Set Cel1 = Nothing
  Set cellule = Nothing
  Set value1 = Nothing
End Sub



Thank you in advance for your support :)
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,090
Latest member
fragment

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