Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Excel column "A" more than Duplecate Names(in Different locations same Company Name),
Column "B" Person Name, Column "C" location Name. Column "D" Value. Column "E" %Value 
Column "F" Date given.



Example:
XYZ C***ry						
Company Name	Person	Lacation	Value	%Value	Date	
ABC Company	aaaa	Location1	Value1	%Value1	1/12/2022	
ABC Company	aaaa	Location2	Value2	%Value2	1/14/2023	
ABC Company	bbbb	Location3	Value3	%Value3	2/15/2023	
CDE Company	eeee	Location4	Value4	%Value4	7/16/2023	
EFG Company	ffff	Location5	Value5	%Value5	2/12/2022	
EFG Company	ffff	Location6	Value6	%Value6	3/24/2023	
						
						
I need This output for Dynamic selection below Output is Save in Separate Woksheet						
						
Country Name	Company Name	Person	Lacation	Value	%Value	Date
XYZ C***ry	ABC Company	aaaa	Location2	Value2	%Value2	1/14/2023
XYZ C***ry	ABC Company	bbbb	Location3	Value3	%Value3	2/15/2023
XYZ C***ry	CDE Company	eeee	Location4	Value4	%Value4	7/16/2023
XYZ C***ry	EFG Company	ffff	Location6	Value6	%Value6	3/24/2023


What I have tried:

Sub AddData()
    Dim LastRow As Long
    LastRow = Sheets("Sheet2").Cells(Rows.Count, "B").End(xlUp).Row
    Sheets("Sheet2").Range("A1:A" & LastRow).Value = "Data"
End Sub



For Each Row In selRange.Rows
       If Row.Cells(1, 1) <> "" Then
           Row.Offset(0, 3).Cells(1, 1) = Row.Cells(1, 1) + Row.Cells(1, 2)
       End If
   Next

   ' clear result range before filling
   Set UniqueRange = Range(resultDataRange)
   UniqueRange.Clear

   Set UniqueRange = Range(resultKeyRange)
   index = resultIndex ' see note above regarding dynamic range

   For Each cell In UniqueRange.Rows
       cell.Formula = "=IFERROR(INDEX(" + keyRange + _
           ", MATCH(0,INDEX(COUNTIF($D$8:D" + CStr(index) + _
           "," + keyRange + "),0,0),0)), """")"
       index = index + 1
Posted
Updated 20-Apr-23 4:23am

1 solution

Most of the work was done in the last answer, how you output the results is capturing the value or a cell reference to the value and outputting that to a cell in the row.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900