Consulting

Results 1 to 2 of 2

Thread: Caculate From One Cell & a Dimension Table

  1. #1
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    1
    Location

    Question Caculate From One Cell & a Dimension Table

    Hi all,

    I want to creat a function to calculate weight and thickness of a order ID (with list products).
    But list of products and quantity are recorded in a cell.
    Can VBA creat this function or not?

    See attached file to see the details

    Thank so much.
    Attached Files Attached Files

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    470
    Location
    Hi phiden!
    Something like below.
    Sub test()
    Dim i&, j&, n&, arrTmp, rng As Range, rng1 As Range, strTmp$
    Set rng = [a3].CurrentRegion
    Application.ScreenUpdating = False
    For i = 2 To rng.Rows.Count
        strTmp = Replace(Replace(rng(i, 3), "(", ""), ")", ",")
        arrTmp = Split(strTmp, ",")
        strTmp = ""
        For j = 0 To UBound(arrTmp) Step 2
            Set rng1 = Columns("g").Find(arrTmp(j + 1), lookat:=xlWhole)
            If Not rng1 Is Nothing Then
                strTmp = strTmp & "+" & arrTmp(j) & "*H" & rng1.Row
            Else
                strTmp = strTmp & "+""Not Found!"""
            End If
        Next j
        strTmp = "=" & Mid(strTmp, 2)
        rng(i, 4) = strTmp
        rng(i, 5) = Replace(strTmp, "H", "I")
    Next i
    Application.ScreenUpdating = True
    End Sub

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •