+ Reply to Thread
Results 1 to 8 of 8

Keep Duplicate in another column and sum to one place

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 365
    Posts
    1,255

    Keep Duplicate in another column and sum to one place

    Hi,
    I have a data in 'Data' sheet where there are a list of data in B,C,D columns.B columns has the code which might be repeated.Hence,I want the code to be unique of B column and C column data of additional to be in E column.Remaining D column data to be added.Results has been mentioned in 'Expected' sheet.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi, try this !


    According to your attachment a VBA demonstration as a beginner starter :

    PHP Code: 
    Sub Demo1()
            
    Dim Rw As RangeV
       With Sheets
    (1)
           .
    UsedRange.Offset(1).Clear
            Application
    .ScreenUpdating False
        
    For Each Rw In Sheets(2).UsedRange.Rows
            V 
    Application.Match(Rw.Cells(1), .UsedRange.Columns(1), 0)
         If 
    IsError(VThen
            Rw
    .Copy .UsedRange.Rows(.UsedRange.Rows.Count)(2)
         Else
          
    With .UsedRange.Rows(V).Cells
           
    .Item(3) = .Item(3) + Rw.Cells(3)
            If 
    Rw.Cells(2) <> .Item(2Then If InStr(.Item(4), Rw.Cells(2)) = 0 Then _
                 
    .Item(4) = .Item(4) & IIf(.Item(4) = """"" ¤ ") & Rw.Cells(2)
          
    End With
         End 
    If
        
    Next
       End With
            Application
    .ScreenUpdating True
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 08-16-2023 at 07:18 AM. Reason: optimization ...

  3. #3
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 365
    Posts
    1,255

    Re: Keep Duplicate in another column and sum to one place

    I think I am not getting the result.I have removed the data from 'Expected' sheet (which is my real outcome) and run your above code in 'Expected' sheet but not getting the exact result as mentioned in 'Expected' worksheet.

    Pls reference the main source sheet name 'Data'.From this the expected result should be derived.

    Those are sample data only, infact there are large data in actual.
    Last edited by paradise2sr; 08-16-2023 at 09:29 AM.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Keep Duplicate in another column and sum to one place


    As I wrote « according to your attachment » so you must obviously test with the same attachment as it is !
    And like any VBA procedure for starters you may have to fit it for what you misexplained / forgot as proceeding like
    you did in your initial post means you are enough confident with your Excel / VBA skills to fit any code helpers may share,
    if it's not the case such initial post has no sense …

  5. #5
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 365
    Posts
    1,255

    Re: Keep Duplicate in another column and sum to one place

    What I did is that I inserted your code in a module and simply run in sheet'Expected' after deleting those results,so that same result may appear by running your code.

    Let me explain again about source data in 'Data' worksheet.Colymn B2 and below are the code that might get repeated twice or thrice and so on.C2 and below are the name assigned to those codes.Here in C column names looks to be similar.D2 and below are the numerical values.
    What I want is that,I want only one code of B column with only name i.e first name assigned of column and added value in one place of D column.Rest similar names to be in right side say at E,F,etc column for twice or thrice.In sample in E column represents of twice in worksheet'Expected'.Thrice would have been in F column.
    I hope this make easy to understand.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Keep Duplicate in another column and sum to one place


    As this is exactly what does my starter VBA demonstration, just try it at least with your initial post attachment …

  7. #7
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 365
    Posts
    1,255

    Re: Keep Duplicate in another column and sum to one place

    Today,I tried keeping cell pointer at B1 in 'Expected' sheet. Then it worked. Very unusual type.However, the work is done.

    Thanx Marc for the help.

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Keep Duplicate in another column and sum to one place


    As my VBA demonstration does very not care of the cell pointer neither which is the active sheet …

    And thanks to do not forget the advise under the code !

+ 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] place duplicate at column R to Y
    By makinmomb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2022, 06:57 AM
  2. Take duplicate cells with different results and place on one line
    By manleyjd14 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-24-2022, 03:13 PM
  3. [SOLVED] Remove duplicate and place on one row
    By Tobbe97 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-23-2021, 01:23 PM
  4. find all duplicate values and place random number next to them?
    By tsiguy96 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2016, 05:39 PM
  5. [SOLVED] Macro to duplicate worksheet and place at end of workbook?
    By Hambone70 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2013, 12:11 PM
  6. Replies: 1
    Last Post: 06-01-2013, 01:27 AM
  7. code to duplicate three columns, always inserting in set place
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2012, 08:38 AM

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