+ Reply to Thread
Results 1 to 6 of 6

VBA Codes to do unique part codes from one column and also sum of these

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-19-2010
    Location
    INDIA
    MS-Off Ver
    MSoffice-2019
    Posts
    339

    VBA Codes to do unique part codes from one column and also sum of these

    Hi,

    Plaese refer my attachment.

    I have stucked in my working and it is so lenghty.There are 32 sheets consists in my original working file.

    In my attachment,I want to do this working through VBA codes instead of Excel formula one by one sheet.

    Required to do from VBA codes of unique column B,C and D on Column J,K,and L and also put their total on M and O.

    Besides these,one extra column should appear i.e.Column N and it is the value of column O divid by column M.

    Can it be posible through VBA Codes ?
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA Codes to do unique part codes from one column and also sum of these

    So...Must Unique B|C|D of each sheet be populated in Col's J to O of each sheet...
    Is the data in first sheet J-O as a example...
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    02-19-2010
    Location
    INDIA
    MS-Off Ver
    MSoffice-2019
    Posts
    339

    Re: VBA Codes to do unique part codes from one column and also sum of these

    Yes sir it is.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA Codes to do unique part codes from one column and also sum of these

    Sub J3v16()
    Dim Data, Dict As Object, ws As Worksheet, str As String, i As Long
    Application.ScreenUpdating = False
    Set Dict = CreateObject("scripting.dictionary")
    For Each ws In Sheets
        With ws
            Data = .Range("B7:G" & .Cells(.Rows.Count, 2).End(xlUp).Row)
            For i = 1 To UBound(Data)
                If Not IsEmpty(Data(i, 1)) Then
                    str = Join(Array(Data(i, 1), Data(i, 2), Data(i, 3)), ";")
                    If Not Dict.exists(str) Then
                        Dict.Add str, Data(i, 4) & ";" & Data(i, 6) / Data(i, 4) & ";" & Data(i, 6)
                    Else
                         Dict.Item(str) = Split(Dict.Item(str), ";")(0) + Data(i, 4) & ";" & Data(i, 6) / Split(Dict.Item(str), ";")(0) & ";" & Split(Dict.Item(str), ";")(2) + Data(i, 6)
                    End If
                End If
            Next i
            Range("J6").Resize(, 6) = Range("B6").Resize(, 6).Value
            With .Range("J7").Resize(Dict.Count)
                .Value = Application.Transpose(Dict.keys)
                .TextToColumns .Cells(1), xlDelimited, Semicolon:=True
                With .Offset(, 3).Resize(Dict.Count): .Value = Application.Transpose(Dict.items)
                    .TextToColumns .Cells(1), xlDelimited, Semicolon:=True
                End With
            End With
            .Columns.AutoFit
        End With
    Next ws
    Application.ScreenUpdating = True
    End Sub

  5. #5
    Forum Contributor
    Join Date
    02-19-2010
    Location
    INDIA
    MS-Off Ver
    MSoffice-2019
    Posts
    339

    Re: VBA Codes to do unique part codes from one column and also sum of these

    Thanks sir for awesome help

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA Codes to do unique part codes from one column and also sum of these

    .........................
    Thanks.png

+ 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. [SOLVED] Finding out the difference between two sets of codes -repetitive codes and interchanged
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2020, 07:05 AM
  2. [SOLVED] Compare JSON data and splitting into corrected codes, deleted codes and added codes
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-01-2020, 06:46 AM
  3. [SOLVED] Compare JSON data and splitting into corrected codes, deleted codes and added codes
    By chandramouliarun in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-29-2020, 12:06 PM
  4. How to extract unique code from a column having multiple codes in is cell
    By Antor Ray in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-02-2019, 02:03 PM
  5. [SOLVED] Convert Y Codes from one column to another based on Unique Codes
    By ashishmehra2010 in forum Excel General
    Replies: 2
    Last Post: 10-06-2015, 09:49 PM
  6. Replies: 5
    Last Post: 02-20-2010, 05:52 AM
  7. Replies: 6
    Last Post: 11-28-2006, 01:08 PM

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