Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3390606
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:42:40+00:00 2026-05-18T03:42:40+00:00

I have a large list of text strings. I know that some strings occur

  • 0

I have a large list of text strings. I know that some strings occur more than once in this list. The frequency with which the strings occur are in the next column.

Now, let’s say the text string “hello” occurs 17 times. How would I get all positions of this text within the list?

Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:42:41+00:00Added an answer on May 18, 2026 at 3:42 am

    Asuming that all your strings are in one column, you can add a second column with their position (line number) and do a pivot table across the strings displaying the counts.

    In order to get the position(s) of a string you are interested in, you use the pivot table’s drill-down function (double click on the count next to a string) which will create a new sheet with all detail records – and the position will be displayed

    Hope that helps

    Good lock

    EDIT after comments exchanged:

    I would go for a solution that scans your data only 1 time and not recursively, copying values to a second sheet:

    for each string in sourcetable
       if found in targettable
          increase targettable.counter by 1 (remark: in column_2)
       else
          put sourcetable.string at end of targettable
          put "1" in targettable.counter (remark: occurence = 1 in column_2)
       endif
       put sourcetable.index into targettable.column(counter+2)
    next
    

    so far the metacode …. do you need more help to actually code this in VBA?

    EDIT 2

    OK …. made a quick & dirty one ….

    Sub CountString()
    Dim S As Range, T As Range, Idx As Long, Jdx As Long
    
        Set S = Worksheets("Sheet1").[A2] ' first row is header
        Set T = Worksheets("Sheet2").[A2] ' first row is header
        Idx = 1
    
        Do While S(Idx, 1) <> ""
            Jdx = FindInRange(T, S(Idx, 1))
            If T(Jdx, 1) = "" Then
                T(Jdx, 1) = S(Idx, 1)
                T(Jdx, 2) = 1
                T(Jdx, 3) = Idx
            Else
                T(Jdx, 2) = T(Jdx, 2) + 1
                T(Jdx, T(Jdx, 2) + 2) = Idx
            End If
            Idx = Idx + 1
        Loop
    End Sub
    
    Function FindInRange(R As Range, A As String) As Long
    Dim Idx As Long
    
        Idx = 1
        Do While R(Idx, 1) <> ""
            If R(Idx, 1) = A Then
                Exit Do
            End If
            Idx = Idx + 1
        Loop
        FindInRange = Idx
    End Function
    

    tested with 500 words from “Lorem ipsum” – takes below 1 second, output in sheet_2 looks like

    String     Count   Position ...                                                        
    Lorem        1        1                                                        
    ipsum        6        2        45        65       232       323       462                
    dolor        5        3        42       214       321       335                        
    sit          6        4        79       148       249       295       415                
    amet         6        5        80       149       250       296       416                
    consectetur  8        6       117       288       298       396       457       473        486
    adipiscing   3        7       180       402                                        
    

    Hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some columns that contain a large amount of data (text, etc), and
i have a large list of static data from a server that i load
I have a rather large list of data that contains 5 properties per element.
I have a large table with list of scores like this, one score per
I have a (derived) Menu control, that displays a rather large list of items
I have a list of strings that are all early modern English words ending
I have a very large (~8 gb) text file that has very long lines.
I have a list of Person s each which have multiple fields that I
So I have this pretty large XML file (40MB) that I'll have to repeatedly
I have a large list of phrases (single and multiple words; some overlapping) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.