+ Reply to Thread
Results 1 to 7 of 7

VBA decode column and fill in values

  1. #1
    Registered User
    Join Date
    04-12-2021
    Location
    us
    MS-Off Ver
    365
    Posts
    6

    VBA decode column and fill in values

    I have been trying to figure out for a week how I can get this to work. But in the example column G is the Position represented by numbers, Column H shows the parent for all the Childs or what each part goes inside. I cant think of a formula or formulas or VBA that can decode this. Any help is apricated. I have 750 files like this. I have attached a File.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: VBA decode column and fill in values

    PHP Code: 
    Option Explicit
    Sub decode
    ()
    Application.ScreenUpdating False
    Dim Lr
    &, k&, cell As Rangesarr()
    Lr Cells(Rows.count"A").End(xlUp).Row ' define last row of column A
    ReDim arr(1 To Lr - 3, 1 To 1)
    '
    Copy A:D to G:K
    Range
    ("G:K").Clear
    Range
    ("A1:D" Lr).Copy Range("G1")
    Range("H:H").Insert
    Range
    ("G:K").Columns.AutoFit
        
    For Each cell In Range("G4:G" Lr' loop through each cell in column G
            k = k + 1
            s = Split(cell, ".")
            Select Case cell.Value
                Case Is = ""
                    arr(k, 1) = ""
                Case Is = "Position"
                    arr(k, 1) = "New Position"
                Case Else
                    If UBound(s) = 0 Then ' 
    Parentlevel 1
                        arr
    (k1) = Range(Cells(1"I"), cell.Offset(02)).Find("Part #", , , , xlPrevious).Offset(10)
                    Else 
    ' Parent: level >1
                        arr(k, 1) = Range(Cells(1, "G"), cell).Find(Left(cell, Len(cell) - Len(s(UBound(s))) - 1), , , , xlPrevious).Offset(0, 2).Value
                    End If
            End Select
        Next
    Range("H4").Resize(k, 1).Value = arr
    Application.ScreenUpdating = True
    End Sub 
    Attached Files Attached Files
    Quang PT

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,573

    Re: VBA decode column and fill in values

    kpx4890,

    Are you sure about the result in 2nd list of PL601007-30?
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-12-2021
    Location
    us
    MS-Off Ver
    365
    Posts
    6

    Re: VBA decode column and fill in values

    The color dont matter and yes it is just a more complicated Bill of materials and there is a mistake at the end. I can fix it and show you. So the color was the show you where the numbers came from.

    uploaded Book2.1

    Thank you
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,573

    Re: VBA decode column and fill in values

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-12-2021
    Location
    us
    MS-Off Ver
    365
    Posts
    6

    Re: VBA decode column and fill in values

    Hello, I have been trying to get this to with my original file but its giving me a bug error. Cell D1 is the cell i would use that was blue in my original file. for the single digit potion cell D1 value goes there. Thank you for the help, I tried a few variation to get the vba code to work but seems to only work in book 2
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,573

    Re: VBA decode column and fill in values

    1) Which code are you referring to?

    2) Why are you changing data layouts time to time?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel formula to fill column B with unique values from column A
    By CV_Sam in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-24-2022, 09:29 AM
  2. How do I colour fill cells in Column A based on values in Column B
    By bearcovier in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-17-2019, 08:12 AM
  3. Replies: 8
    Last Post: 07-04-2018, 10:03 AM
  4. [SOLVED] Fill up a column in one work sheet by matching column values in 2 worksheets
    By marimuthuravi in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-11-2018, 11:38 PM
  5. [SOLVED] How to fill an array with values in column C based on Column D date value of Today
    By jrtraylor in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2016, 07:44 PM
  6. [SOLVED] Find Values in Column A and fill identical values in Column B
    By deviltronics in forum Excel General
    Replies: 6
    Last Post: 10-07-2014, 05:25 PM
  7. [SOLVED] vba to fill values till end of text values in B:B column.
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2014, 03:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1