+ Reply to Thread
Results 1 to 6 of 6

Store String Values to Avoid Re-Using

  1. #1
    Registered User
    Join Date
    06-21-2018
    Location
    Calgary, AB
    MS-Off Ver
    2013
    Posts
    94

    Store String Values to Avoid Re-Using

    Hello friends!

    I have a macro that loops through a column, and for each cell in that column, assigns the value to the string variable "railcar".
    The problem is that there can be duplicates of these values.

    Normally I would remove the duplicates, but the duplicates are also important.
    Is there a way to store the values so that once a string has been used, the cell will be flagged if it is reused?

    I know I can also just identify and highlight the duplicates manually, but there are other processes that occur once the string has been assigned.

    Thanks for any and all answers!
    never stop learning. or milk

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Store String Values to Avoid Re-Using

    What do you want to happen when a duplicate is encountered?
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Store String Values to Avoid Re-Using

    Conceptually, you could store unique value occurrences on a separate sheet, then as you are looping through you can check to see if that string exists already, or you can store the values in a string list in memory (faster, but not persistent)

    In practice, upload a sample workbook and it will help us work through your use case.


    Thank you

  4. #4
    Registered User
    Join Date
    06-21-2018
    Location
    Calgary, AB
    MS-Off Ver
    2013
    Posts
    94

    Re: Store String Values to Avoid Re-Using

    Hi Norie, thanks for the reply.

    Please see the below code:

    Please Login or Register  to view this content.
    As you can see, after it finds the value it sets an adjacent cell value to the offloaded date from the other worksheet.
    Since it is looping through the column to get the railcar value, and then for each cell starting at the top of the search column to match it, it will pick the date for the first match it encounters.

    I would like it to go to the next instance of the value, and then use that date, etc, etc

    Does this make sense?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Store String Values to Avoid Re-Using

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.

  6. #6
    Registered User
    Join Date
    06-21-2018
    Location
    Calgary, AB
    MS-Off Ver
    2013
    Posts
    94

    Re: Store String Values to Avoid Re-Using

    Hi Norie,

    Thanks again. I understand that that would be hugely useful unfortunately, a lot of the data involved is confidential as per work policy. I can try and drum up an example workbook if that's necessary.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. trying to convert string variable to barcode font and store as new string var
    By mike_tako in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 05-11-2018, 04:36 PM
  2. How can I store more than 255 charachters in a VBA string?
    By kbdb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2017, 06:00 AM
  3. Store different values then string as dictionary item
    By jaryszek in forum Excel General
    Replies: 1
    Last Post: 11-16-2017, 04:06 AM
  4. store cells value as a string variable
    By sebdor in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-02-2014, 03:31 PM
  5. How can i avoid the String of Characters While converting fraction values
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-10-2014, 07:52 AM
  6. Avoid String been converted to decimals in CSV files.
    By krishnarao in forum Excel General
    Replies: 1
    Last Post: 06-11-2009, 09:19 AM
  7. seprate and store string in arrays
    By ilyaskazi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-29-2005, 10:22 AM

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