Autofiltering and filling the values in the corresponding columns of the rows

sekar

New Member
Joined
Feb 2, 2009
Messages
36
Office Version
  1. 2010
Platform
  1. Windows
Hi,
with the following data, i am autofiltering the Article column using the scripting dictionary, and cycling through each article, i am clueless how to apply the following based on the condition.

Case 1
When Backsheet (3.5mm) in column D with respect to the Article (column C) (001.WU_1D1S_450) means Height Ghadi (column K)has to be filled as HG in the corresponding rows of the Panel - Top, Panel - Right,Panel - Left, Panel - Bottom for the article (001.WU_1D1S_450)

similary, wherever the Backsheet (3.5mm), for the respective Article, the rows of the Panel - Top, Panel - Right,Panel - Left, Panel - Bottom has to be filled as HG in the Height Ghadi (column K)

Case 2,
when the column D has Backsheet (3.5mm)_MF, the above procedure is done plus, the Factory check (column L) has to fill the "Minifix-01" for the corresponding rows of the Panel - Top, Panel - Right,Panel - Left, Panel - Bottom of the article. This minixfix-01 has to be incremented as "Minifix-01", "Minifix-02","Minifix-03".

VBA Code:
Sub filter()


    Dim shtSrc As Worksheet, shtDest As Worksheet
    Dim rngSrc As Range, arrSrc As Variant
    Dim lrowSrc As Long, lcolSrc As Long, colSrcFltr As Long
    Dim dictMaterial As Object, dictKey As String, vKey As Variant
    Dim i As Long
    Dim sName As String
    Dim illegalNmChar As Variant
    Dim replaceNmChr As String
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    illegalNmChar = Array("/", "\", "[", "]", "*", "?", ":")
    replaceNmChr = "|"
       
    Set shtSrc = Worksheets("01_CutlistExport_DMH")                                         ' <--- Change to your sheet name
    With shtSrc
        lrowSrc = .Cells(Rows.Count, "B").End(xlUp).Row
        lcolSrc = .Cells(6, Columns.Count).End(xlToLeft).Column
        Set rngSrc = .Range(.Cells(1, "A"), .Cells(lrowSrc, lcolSrc))
        arrSrc = rngSrc
        colSrcFltr = .Columns("C").Column - rngSrc.Cells(1).Column + 1      ' <--- Column letter to use for filtering
    End With
    
    Set dictMaterial = CreateObject("Scripting.dictionary")
    
    ' Load unique materials into Dictionary
    For i = 2 To UBound(arrSrc)
        dictKey = arrSrc(i, colSrcFltr)
        If Not dictMaterial.Exists(dictKey) And dictKey <> "" Then
            dictMaterial(dictKey) = i
        End If
    Next i
    
    If shtSrc.AutoFilterMode Then shtSrc.AutoFilterMode = False

    For Each vKey In dictMaterial.keys
        rngSrc.AutoFilter Field:=colSrcFltr, Criteria1:=vKey
        
        
    Next vKey
 
  


End Sub
TESTT_01_CutlistExport_DMH_231226_12-07-21A.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1Sl.NoORDERNAMEArticleNAMEHeightWidthThicknessQtyHEIGHT GHADIFactory CheckSite CheckMATIDMATCATMATGRIDCLENGCWIDTHFTHKDELIVERY DATEBARCODE1BARCODE2IDTYPCUSTOMER
21TESTT001.WU_1D1S_450Adjusting Shelf414250161DMHT_BWP_RW_16mmHG_Decor_Panel041224818163893,
32TESTT001.WU_1D1S_450Panel - Bottom414295161DMHT_BWP_RW_16mmHG_Decor_Panel041229318163875,
43TESTT001.WU_1D1S_450Panel - Left600295161DMHT_BWP_RW_16mmHG_Decor_Panel059829318163861,
54TESTT001.WU_1D1S_450Panel - Right600295161DMHT_BWP_RW_16mmHG_Decor_Panel059829318163851,
65TESTT001.WU_1D1S_450Panel - Top414295161DMHT_BWP_RW_16mmHG_Decor_Panel041229318163884,
76TESTT001.WU_1D1S_450Backsheet (3.5mm)5804303.51DMHT_BWP_RW_3n5HG_Decor_Panel05804305.5163916,
87TESTT001.WU_1D1S_450Door panel598448161DMHT_HDHMR_RW_16mmMDF059444418163908,
98TESTT002.WU_2D1S_600Adjusting Shelf564250161DMHT_BWP_RW_16mmHG_Decor_Panel056224818163963,
109TESTT002.WU_2D1S_600Panel - Bottom564295161DMHT_BWP_RW_16mmHG_Decor_Panel056229318163945,
1110TESTT002.WU_2D1S_600Panel - Left600295161DMHT_BWP_RW_16mmHG_Decor_Panel059829318163931,
1211TESTT002.WU_2D1S_600Panel - Right600295161DMHT_BWP_RW_16mmHG_Decor_Panel059829318163921,
1312TESTT002.WU_2D1S_600Panel - Top564295161DMHT_BWP_RW_16mmHG_Decor_Panel056229318163954,
1413TESTT002.WU_2D1S_600Backsheet (3.5mm)5805803.51DMHT_BWP_RW_3n5HG_Decor_Panel05805805.5163996,
1514TESTT002.WU_2D1S_600Shutter598298161DMHT_HDHMR_RW_16mmMDF059429418163979,
1615TESTT002.WU_2D1S_600Shutter598298161DMHT_HDHMR_RW_16mmMDF0594294181639810,
1716TESTT003.WU_O1S_300Fixed Shelf264297161DMHT_BWP_RW_16mmHG_Decor_Panel0262295181640413,
1817TESTT003.WU_O1S_300Panel - Top264315161DMHT_BWP_RW_16mmHG_Decor_Panel026231318164034,
1918TESTT003.WU_O1S_300Backsheet (3.5mm)_MF5802803.51DMHT_BWP_RW_3n5HG_Decor_Panel05802805.5164056,
2019TESTT003.WU_O1S_300Panel - Bottom300315161DMHT_HDHMR_RW_16mmMDF029631118164025,
2120TESTT003.WU_O1S_300Side Panel582315161DMHT_HDHMR_RW_16mmMDF057831118164001,
2221TESTT003.WU_O1S_300Side Panel582315161DMHT_HDHMR_RW_16mmMDF057831118164011,
2322TESTT004.WU_2D1S_800Adjusting Shelf764250161DMHT_BWP_RW_16mmHG_Decor_Panel076224818164103,
2423TESTT004.WU_2D1S_800Panel - Bottom764295161DMHT_BWP_RW_16mmHG_Decor_Panel076229318164085,
2524TESTT004.WU_2D1S_800Panel - Left600295161DMHT_BWP_RW_16mmHG_Decor_Panel059829318164071,
2625TESTT004.WU_2D1S_800Panel - Right600295161DMHT_BWP_RW_16mmHG_Decor_Panel059829318164061,
2726TESTT004.WU_2D1S_800Panel - Top764295161DMHT_BWP_RW_16mmHG_Decor_Panel076229318164094,
2827TESTT004.WU_2D1S_800Backsheet5807803.51DMHT_BWP_RW_3n5HG_Decor_Panel05807805.5164136,
2928TESTT004.WU_2D1S_800Shutter598398161DMHT_HDHMR_RW_16mmMDF059439418164119,
3029TESTT004.WU_2D1S_800Shutter598398161DMHT_HDHMR_RW_16mmMDF0594394181641210,
01_CutlistExport_DMH
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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