+ Reply to Thread
Results 1 to 5 of 5

Thread: Need to develop a macro that will make an assortment

  1. #1
    Registered User
    Join Date
    04-28-2009
    Location
    Athens
    MS-Off Ver
    Excel 2007
    Posts
    50

    Unhappy Need to develop a macro that will make an assortment

    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!

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Need to develop a macro that will make an assortment

    George, why not upload your files here directly ?
    (use the Paperclip icon to attach your files)

  3. #3
    Registered User
    Join Date
    04-28-2009
    Location
    Athens
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Need to develop a macro that will make an assortment

    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

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Need to develop a macro that will make an assortment

    Perhaps you want something along the lines of:

    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
    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).

    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.

  5. #5
    Registered User
    Join Date
    04-28-2009
    Location
    Athens
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Need to develop a macro that will make an assortment

    Seems to work like a charm,thanks a lot!!!You can't image all the trouble you got me off!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0