Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Augmenting an integer in a column to reflect duplicates in another


HI All

Hope someone can help me solve a problem.

I need a small piece of VBA to find duplicate values in a selected
column , and then augment a second selected column by the amount found.
The duplicates themselves could then be deleted or hidden.

For example :

Quantity Ref

1 223
1 217
3 223
1 217
1 625


Would become :

Quantity Ref

4 223
2 217
1 625


Columns without duplicates would of course remain untouched.

Because the columns might vary , these would need to be chosen at the
start by the user via popup.

Grateful for any assistance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Augmenting an integer in a column to reflect duplicates in another

Hi Colin,

Am Mon, 9 Jun 2014 23:06:17 +0100 schrieb Colin Hayes:

Quantity Ref

1 223
1 217
3 223
1 217
1 625

Would become :

Quantity Ref

4 223
2 217
1 625


in which columns are your values? Do you need a table with these both
columns without duplicates only? Then the easiest and fastest way is to
create a Pivot table from this two columns.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Augmenting an integer in a column to reflect duplicates in another


in which columns are your values? Do you need a table with these both
columns without duplicates only? Then the easiest and fastest way is to
create a Pivot table from this two columns.


Regards
Claus B.



Hi Claus

The two columns would vary from worksheet to worksheet , so 'Quantity'
and 'Duplicate' columns would need to be entered when the code is run.
Perhaps via message box for the user to enter the column letters.

The worksheet may have many columns. All columns and their content need
to be present after running the code.

The 'Quantity' column would have been updated to reflect the amount of
duplicates found in the other selected column.

Rows with duplicates would be deleted or hidden.

Grateful for your assistance as usual Claus.



Best Wishes

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Augmenting an integer in a column to reflect duplicates in another

Hi Colin,

Am Tue, 10 Jun 2014 14:17:07 +0100 schrieb Colin Hayes:

The worksheet may have many columns. All columns and their content need
to be present after running the code.

The 'Quantity' column would have been updated to reflect the amount of
duplicates found in the other selected column.

Rows with duplicates would be deleted or hidden.


when is a row a duplicate? If all columns are equal or if only "Ref" is
equal?

Your table in sheet1. Then try foolwong code. It copies the table to
sheet2 and let remain the first occurance of "Ref". All other values
will be deleted. And in the Quantity column there are the sums of the
"Refs"
If that is not what you want please send me a workbook with data and
with example how the result should be.

Sub Test()
Dim ColRef As Long
Dim ColQ As Long
Dim LRow As Long

Sheets("Sheet1").UsedRange.Copy _
Sheets("Sheet2").Range("A1")

With Sheets("Sheet2")
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
ColRef = WorksheetFunction.Match("Ref", .Range("1:1"), 0)
ColQ = WorksheetFunction.Match("Quantity", .Range("1:1"), 0)
.Range(.Cells(2, ColRef), .Cells(LRow, ColRef)).Formula = _
"=IF(CountIf(Sheet1!$G$2:G2,Sheet1!G2)=1,Sheet1!G2 ,"""")"
.Range(.Cells(2, ColQ), .Cells(LRow, ColQ)).Formula = _
"=IF(G2="""","""",SumIf(Sheet1!G:G,G2,Sheet1!D:D)) "
End With

End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Augmenting an integer in a column to reflect duplicates in another


Hi Claus

OK I've put sample of what I mean here :

http://www.chayes.demon.co.uk/sample.xls

There are two tabs - before and after. The column queried for duplicates
in this example was O , with the result and update placed in M.

Thanks again Claus




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Augmenting an integer in a column to reflect duplicates in another

Hi Colin,

Am Tue, 10 Jun 2014 17:22:00 +0100 schrieb Colin Hayes:

http://www.chayes.demon.co.uk/sample.xls


please have a look:
https://onedrive.live.com/?cid=9378A...121822A3%21326
for "sampleCH"


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need column to reflect year 2008 dates Jack B Excel Discussion (Misc queries) 6 May 1st 09 05:46 AM
Find duplicates, sum column then delete duplicates aileen Excel Programming 3 December 11th 08 05:03 PM
changing html code to increase column width does not reflect in ex Dev in soup Excel Discussion (Misc queries) 0 July 2nd 08 12:16 PM
how can i subtract single integer value from the entire column naga s chintala Charts and Charting in Excel 5 May 1st 05 01:38 AM
Selecting a column with an integer lashio Excel Discussion (Misc queries) 2 March 27th 05 07:50 PM


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"