Posts by rory

    This line:

    Code
    1. Dim wb_main, wbm_path, wbm_title, wbm_ds, wbm_out, _
    2. wb_data, wbd_path As String


    only declares wbd_path as a String, all the rest are Variants. You need to change it to:


    Code
    1. Dim wb_main As String, wbm_path As String, wbm_title As String, wbm_ds As String, wbm_out As String, _
    2. wb_data As String, wbd_path As String


    and I think you'll find your problem will disappear.

    I get the same protection error with your GetProductsList code. (I've always found the UIO argument a bit hit and miss to be honest) You could use something like this:


    Code
    1. Set rngData = shtFeaturesource.Range("A1").CurrentRegion
    2. Set rngCrit = shtCriteria.Range("K1:K2")
    3. Set rngExt = shtCriteria.Range("K6")
    4. rngExt.CurrentRegion.Offset(1).Clear
    5. With rngData.Columns(2)
    6. .AdvancedFilter xlFilterInPlace, rngCrit, , True
    7. .SpecialCells(xlCellTypeVisible).Copy
    8. End With
    9. rngExt.PasteSpecial xlPasteValues
    10. Set rngExt = rngExt.CurrentRegion

    You don't need to loop to clear all the cells:


    Code
    1. With Sheets("Input").ListObjects("Data")
    2.    .ListColumns("Days Worked").DataBodyRange.ClearContents
    3.    .ListColumns("O/T Hours Worked").DataBodyRange.ClearContents
    4.    .ListColumns("Commission Value").DataBodyRange.ClearContents
    5.    .ListColumns("Advance").DataBodyRange.ClearContents
    6. End With

    Sometimes you need workarounds when there isn't a direct solution to the problem. Also, since you aren't the OP, you can't really say for sure what he/she was looking for. ;) As this post is 6 years old, we're unlikely to find out.

    Just to explain why you are seeing False there:


    Code
    1. Range("K14") = RunTot = Cells(Row, Col) + RunTot


    You have two = signs there, which means that VBA will interpret what is to the right of the first = sign as an expression to be evaluated. Now, as has already been stated, RunTot is never actually calculated in the code, so it will have the default value of an integer, which is 0. So the expression being evaluated is:


    Code
    1. 0 = Cells(Row, Col) + 0


    which will evaluate to True if the value of Cells(Row, Col) is 0, and False otherwise. That result is then put into K14.


    If you actually wanted to store the running total in a variable, you need to split that into two lines:


    Code
    1. RunTot = Cells(Row, Col) + RunTot
    2. Range("K14") = RunTot


    although, as Carim pointed out earlier, there really isn't a lot of need for a variable here.

    Try this - it works for me once I added some data that matched up to the part list:


    Oh - you changed the control it applies to! You also left out the line that actually does the work. Please check the code I posted as you missed out this line:


    Code
    1. GetPartInfoForRange area.Columns(5), area.Columns(2), ODict


    in the For each area loop.