Results 1 to 8 of 8

find how many times a word appears in a string at certain positions within the string

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Question find how many times a word appears in a string at certain positions within the string

    Hi everyone,

    I have strings that are concatenated with ~ characters. an example of the format of the sorts of strings im working with is here:

    (total rows,workbook name,worksheet name,column, top row, bottom row, row 1 data, row 2 data, ... , row total rows-1 data)
    myString = "14~ThisWorkbook.Name~Sheets(1).Name~E~11~25~data0~data1~data2~data3~data4~data5~data6~data7~data8~data9~data10~data11~data12~data13"

    I have kindly been provided with the following code by AlphaFrog which allows me to search this string for a given term and it will count the number of ~ characters to the left of the term.

    code provided by AlphaFrog
    'CharCount = the number of ~ characters to the left of term_to_find within the string myString
    CharCount = InStr(1, myString, term_to_find, 1) - InStr(1, Replace(myString, "~", ""), term_to_find, 1)
    How could I look at this string and count the number of times my term appears only it at certain positions (that is with a certain number of ~ characters to its left).
    The possible positions the term can appear should be restricted to index number 6,13,20,27,..
    by index number i mean the number of ~ characters in front of the term in myString

    so from the above example
    myString index(0) = 14
    myString.index(1) = ThisWorkbook.Name
    myString.index(2) = Sheets(1).Name
    Etc

    The index values to search for should be restricted to those mentioned above.. .. 6,13,20,27,..

    Kind Regards
    Jordan
    Last edited by jordan2322; 02-04-2013 at 09:08 PM.

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1