Tuesday, July 28, 2009

How can i use excel macros to compare two rows with same a/c number but having different balance?

for example row 1 first cell got a./c number cell 2 got the balance and row 2 first cell got same a/c number and cell 2 got the different balance of lets say different day. how can i align/sort the excel sheet to have the same a/c number at different row (cell one contains a/c number and cell 2 and 3 contains the balances of that a/c in different days for example? show me :)

How can i use excel macros to compare two rows with same a/c number but having different balance?
Sounds like you could use a pivot table. I made a macro to create one... based on sheet1, columns A=a/c number, B=date, C=balance. New table created in sheet 2





Sub createpivottable()





ActiveWorkbook.PivotCaches.Add(SourceTyp... SourceData:= _


"Sheet1!R1C1:R8C3").createpivottable TableDestination:=Range("A3"), _


TableName:="PivotTable2"


ActiveSheet.PivotTables("PivotTable2").S... = False


With ActiveSheet.PivotTables("PivotTable2").P... number")


.Orientation = xlRowField


.Position = 1


End With


With ActiveSheet.PivotTables("PivotTable2").P...


.Orientation = xlColumnField


.Position = 1


End With


With ActiveSheet.PivotTables("PivotTable2").P...


.Orientation = xlDataField


.Position = 1


End With


Application.CommandBars("PivotTable").Vi... = False


End Sub





OR you can just open a new sheet, go to data on menu bar, pivot table report, then follow the wizard to build one for you.





that's the easiest thing.





But if this is for a class, here's an idea of where to start...


first find duplicate values in a/c number column...


here's a tutorial on finding duplicate values in excel columns: http://office.microsoft.com/en-us/excel/...





Good luck!


No comments:

Post a Comment