Dear Paul, Thanks you so much its working fine!! I'm still learner and starting of the stair in VBA but you are awesome.
*Suman Kumar* On Wed, Sep 16, 2015 at 7:57 PM, Paul Schreiner <schreiner_p...@att.net> wrote: > OK, here's the approach I took. > First: For Testing purposes I created a sample list of 10,000 rows of data. > they included Company ID's and Names using names selected randomly from a > list of about 400 names. > > Within the list of 10,000 records, there are only 1990 unique Company ID's. > > Because the list is "random", the test data itself isn't very realistic, > so I "assumed" that if the same ID had 4 records, and they happened to be 4 > different names, then the fist name should be used. > At the same time, if of the 6 records had 2 of one name and 2 of another > and two more unique records, the first of the duplicated names would be > used. > > Again, in real-world lists, this probably wouldn't be an issue, but it was > easier to make the program assume this approach than take a couple of hours > to generate a realistic list of sample data. > > For testing purposes, I put the data into a sheet called "Sheet1(orig)" > and copy this sheet to "Sheet1" to begin. > In "real-world" applications, this "Restore_Sheet1" function can be > replaced with code to read the data from the original source. > > --------------- > The macro utilizes two Data Dictionaries. > One is for company ID's and contains the unique names (in an array) for > each ID. > The other is the COUNT of unique ID/Name combinations. > > I first read through the 10,000 records and load the dictionary objects. > then, I looped through the dictionaries and replaced the arrays of names > with the "best" name based on number of occurrences. > The result is a Data Dictionary of "Best" names for each ID. > > I then updated the 10,000 rows with the "Best" name for each ID. > > the 10,000 rows are processed in about 4 seconds. > > Just to see how it works, I copied the data to create 100,000 rows and ran > the macro. > > It took about 22 seconds. > > Because I'm not doing any screen/display manipulations (except when I > update the names) > Adding Application.Screenupdating = false > only knocks off about 2 seconds. > > hope this gives you something to adapt to your needs. > > *Paul* > ----------------------------------------- > > > > > > > > *“Do all the good you can,By all the means you can,In all the ways you > can,In all the places you can,At all the times you can,To all the people > you can,As long as ever you can.” - John Wesley* > ----------------------------------------- > > ------------------------------ > *From:* Suman <ksuman1...@gmail.com> > *To:* "excel-macros@googlegroups.com" <excel-macros@googlegroups.com> > *Sent:* Wednesday, September 16, 2015 7:46 AM > > *Subject:* Re: $$Excel-Macros$$ Company name based on maximum occurrence > > Dear Paul, > I can understand macro and modify too according to needs while > implementing in my workbook. You can make the module on the basis of my > previous attachment. Secondly, 1 lack data means 1 lack rows. Sorry for the > confusion about the same. > > > Regards, > Suman Kumar > > > > > > On Wed, Sep 16, 2015 at 4:08 PM, Paul Schreiner <schreiner_p...@att.net> > wrote: > > I'm not sure what you mean by "1 lack data". > > To help with a macro, there's much more I need to know. > > First and foremost is: > How much do you know about macros? > If I were to write a macro and post it, would you be able to implement it > in your workbook? or would I need to send you an entire workbook? > > If you changed something in the workbook and the macro quit working, would > you be able to debug the macro to find the problem? > > Next: > What does your workbook look like? > How is the data updated? > What do you want the end result to look like? > > I mean: instead of having the macro write the most common name in another > column, would it be better to simply change the name in the existing column? > > it would be better for me to have a sample file to work with. > Otherwise, I'd spend as long, or longer, trying to put together sample > data that may not even match your data! > > *Paul* > ----------------------------------------- > > > > > > > > *“Do all the good you can,By all the means you can,In all the ways you > can,In all the places you can,At all the times you can,To all the people > you can,As long as ever you can.” - John Wesley* > ----------------------------------------- > > ------------------------------ > *From:* Suman <ksuman1...@gmail.com> > *To:* "excel-macros@googlegroups.com" <excel-macros@googlegroups.com> > *Sent:* Wednesday, September 16, 2015 5:15 AM > > *Subject:* Re: $$Excel-Macros$$ Company name based on maximum occurrence > > Thank you so much Mr. Paul its working!! > > This requirement is for Weekly basis and need to work on approximate 1 > lack data. Can you please help to provide the macro for the same? > > > > > > > > > > *Suman Kumar* > > > > On Tue, Sep 15, 2015 at 6:17 PM, Paul Schreiner <schreiner_p...@att.net> > wrote: > > Seriously? Vlookup? how exactly would that work? > > dear Suman: > > There are MANY ways of doing this. > choosing the "best" depends on several things. > Like: > What version of Excel are you using? > how many records do you have? > how often do you need to do this? > Are you looking for a solution using Excel functions or macros? > > If this is a "one time" thing, then we can use a "helper" column > to count occurrences. > Then sort in decreasing order and use vlookup to find the first entry. > > If you're using Excel2007 or greater, you can use =Countifs() > (which is countif with multiple criteria) > > in D2, put: > =COUNTIFS(A:A,A2,B:B,B2) > and copy down. > > Then, sort by column A and D (with D sorted largest to smallest) > Then, in column C, put: > =VLOOKUP(A2,A:B,2,FALSE) > and copy down. > > if you need a more elaborate or macro solution, let us know. > > *Paul* > ----------------------------------------- > > > > > > > > *“Do all the good you can,By all the means you can,In all the ways you > can,In all the places you can,At all the times you can,To all the people > you can,As long as ever you can.” - John Wesley* > ----------------------------------------- > > ------------------------------ > *From:* Prabhu Pinky <prabhupin...@gmail.com> > *To:* excel-macros@googlegroups.com > *Sent:* Tuesday, September 15, 2015 8:24 AM > *Subject:* Re: $$Excel-Macros$$ Company name based on maximum occurrence > > Use vlookup. > > > On 15-Sep-2015 5:31 PM, "Suman" <ksuman1...@gmail.com> wrote: > > Dear All, > If we have list of company id & Name in excel cell then how can I find > maximum occurrence of company name against that company ID. > > Example: > Co IDNameRequired Output1AA1AA1AA1AA1AA1AA1BA1BA1BA2CD2DD2DD2DD > > > Regards, > Suman > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.