I am looking for an excel macro (i am using 07 office but i can get an 03 if that's a problem :-) )
So,what i am looking for is a macro that will search in column B for some codes,example: 0403874700197 but count only the numbers between the 5th (aka 8 ) and prelast (aka 12th number,in this case 9,),so we have the code 87470019.
Then every code on column B has it's D column wich has some numbers.
So what will the macro do?Take column B,start with line no 1,take the code and search for similiar,counting only from 5th to 12th letter,
in all the workbook,after find all the similiar codes it will see their D columns,sum them to column D at the line wich it find the first code.Then take line No 2,see if the D cell is empty,pass,if not search for similiar codes in column B...and goes on.It's important to delete the numbers to D cells that already has summed!
I know it's a tough one,but any help would be much appreciated it (plus it can get my happiness back!)
To unterstand it better i have uploaded two excels,one as it is and one after i have done this whole thing manually.What im trying to get here is an assortment (if you can tell me a better way please do! ) of all these codes...anyway,the link to download the example if interested:
http://rapidshare.com/files/226647243/Example.rar
Thank you anyway
George
Last edited by alogoc; 05-18-2009 at 03:20 AM. Reason: Solved!
George, why not upload your files here directly ?
(use the Paperclip icon to attach your files)
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Hehe,sorry!!I just registered and i'm new to forum!
Anyway,the files are these:
As it is before my process :
ΠΤΟΛΕΜΑΙΔΑ-210.xls
As it is done:
ΠΤΟΛΕΜΑΙΔΑ-210done.xls
Any help would be much appreciated!
PS The description is in Greek language but has nothing to do with the macro,just letting you know...
Best regards
George
Perhaps you want something along the lines of:
This uses a temp formula column in E which is subsequently deleted, the results of which are pasted to Column D (over the original values).Public Sub CreateAggregates() With Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp)).Offset(, 4) .FormulaR1C1 = "=IF(COUNTIF(R1C2:RC2,""*""&MID(RC2,5,8)&""*"")=1,SUMIF(C2,""*""&MID(RC2,5,8)&""*"",C4),"""")" .Offset(, -1).Value = .Value .Clear End With End Sub
The only discrepancy between the above and your desired output relate to rows 48:53, I could not establish as to why these should not be aggregated as per the other lines.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Seems to work like a charm,thanks a lot!!!You can't image all the trouble you got me off!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks