+ Reply to Thread
Results 1 to 5 of 5

Looking for a way to identify and store different strings

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Looking for a way to identify and store different strings

    I have a sheet which can be of any number of rows, Column Y contains a text string. On one sheet it may be the same string on every row, on another it may have any number of different strings (not necessarily in ordered blocks).
    so what I am trying to achieve is to scan down the list, locate a string that has not been used before, store it in a variable and move on with other code, then return to the list and repeat.
    Something like:
    for x = 2 to endoflist
    'find unique string
    'store string in variable
    call rest_of_code
    next

    I hope I have explained this OK, unfortunately it is difficult for me to post a sample as this is part of a large project

    any help or pointers in the right direction would be most appreciated.
    Last edited by tryer; 11-17-2011 at 10:00 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Looking for a way to identify and store different strings

    'Unique' is a relative property: you can only determine it's uniqueness comparing it to something else. When will you consider a string 'unique'. You have to specify it first.
    Besides you can always post a sample workbook that only takes your question into account. 'Being a part of a larger project' can't be a reason not to provide potential helpers essential information.



  3. #3
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: Looking for a way to identify and store different strings

    snb. Thank you for your answer, I didn't think I expalined it very well. In this case unique is meant as not the same as another already processed. I have made up a sample from which you will see column Y contains city or country names. There are in fact 7 different 'unique' strings within this list so I would like the main code to run 7 times, each time with one of the names stored within the variable.

    Thanks again for your time and I'm sorry for not explaining accurately enough.
    Attached Files Attached Files

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Looking for a way to identify and store different strings

    to get the unique items in column Y into column Z
    to put them into array sn
    to clear column Z

    sub snb
      columns(25).advancedfilter xlfiltercopy,,cells(1,26),true
      sn=columns(26).specialcells(2)
      columns(26).clearcontents
    end sub

  5. #5
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: Looking for a way to identify and store different strings

    Thank you snb that gives me a good place to start

+ Reply to Thread

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