Solved

VBA Code

Posted on 2014-04-30
5
148 Views
Last Modified: 2014-04-30
Hi guys,

Attached you will find a sample of what the data is and the desirable result if it is possible.
Thank a lot,
Example.xls
0
Comment
Question by:marian68
  • 2
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
Ejgil Hedegaard earned 250 total points
Comment Utility
Formula in B18, copy down, see file

=B2&IF(COUNTIF($B$2:$B$10,B2)>1,"("&COUNTIF($B$2:B2,B2)&")","")
Example-word-count.xls
0
 

Author Comment

by:marian68
Comment Utility
Thank you,

The formule will work even for 10000 records?
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 250 total points
Comment Utility
Try this macro

Sub wordnums()
    Dim ws As Worksheet
    Dim lcel As Range
    Dim scel As Range
    Dim cel As Range
    Dim wrd As String
    Dim ctr As Long
    Set ws = ActiveSheet
    Set lcel = Range("B1").End(xlDown)
    For Each cel In Range("B2", lcel)
        If WorksheetFunction.CountIf(cel.EntireColumn, cel) > 1 Then
            wrd = cel.Value
            ctr = 1
            For Each scel In Range(cel, lcel)
                If wrd = scel Then
                    scel.Value = scel & "(" & ctr & ")"
                    ctr = ctr + 1
                End If
            Next scel
        End If
    Next cel
End Sub
0
 

Author Closing Comment

by:marian68
Comment Utility
Thank you guys.
0
 
LVL 20

Expert Comment

by:Ejgil Hedegaard
Comment Utility
The formula will work for 10000 records, but will take a while to calculate.
My test took 1 minute to copy and calculate, so when done, I would leave the formula for the first record, and convert the rest to values.
With the formula at the first record, recalculation can always be done again.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now