Solved

VBA Code

Posted on 2014-04-30
5
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
Ejgil Hedegaard earned 250 total points
ID: 40032827
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
ID: 40032837
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
ID: 40032858
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
ID: 40033045
Thank you guys.
0
 
LVL 22

Expert Comment

by:Ejgil Hedegaard
ID: 40033065
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Microsoft Excel - Select All Computers and Specific Applicaiton 2 26
Excel VBA Script 9 57
Vlookup Help 3 29
Create a list of Worksheets based on Cell Value 14 27
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

734 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