+ Reply to Thread
Results 1 to 5 of 5

Unable to decipher what is wrong with the loop

  1. #1
    Registered User
    Join Date
    01-15-2020
    Location
    Philippines
    MS-Off Ver
    365
    Posts
    3

    Post Unable to decipher what is wrong with the loop

    I'm writing a function that will get a string and split it into words and apply formatting to each word accordingly (based on my rules).
    For example: JOHN ALPHA BRAVO will be John Alpha Bravo and AD67 TRIALS willl become AD67 Trials. Something like that.

    Anyway, I'm only in the beginning of my code and can't quite comprehend why it won't work.
    I wrote the following code to split the text and put them into an array. I can fill the 1st slot in the array but the For loop won't continue.
    It does not return any error whatsoever so I really don't know what to do.

    Please Login or Register  to view this content.
    At the moment, words(0) is equal to John, words(1) is blank and so is words(2).

    Thank you in advance for anyone that'll take their time and help me!
    Attached Files Attached Files
    Last edited by 6StringJazzer; 01-15-2020 at 01:24 PM. Reason: Changed QUOTE tags to CODE tags

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    As you do not ever need an array neither any loop !
    Just using an easy Excel Basics worksheet function (aka PROPER) even under VBA …

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,986

    Re: Unable to decipher what is wrong with the loop

    The way to do this is:

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 01-15-2020 at 01:30 PM.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    01-15-2020
    Location
    Philippines
    MS-Off Ver
    365
    Posts
    3

    Re: Unable to decipher what is wrong with the loop

    I'm sorry I was not being clear, the examples I gave were just simple examples.
    I know I can use PROPER no biggie, and if there is some number use UPPER.

    But it's not that simple. I have strings that are compounded words, for example "JOHNDATA" which I want the function to translate to JohnData.
    I also have short strings that are acronyms like, "MBC" which I want the function to translate to MBC. But I also have short strings that are not acronyms like, "THE", "FOR" which I want the function to translate to The and for respectively. I also have four-letter and two-letter strings like "BANK" "OF" "ROCK" "MCIO" which should end up in different CASES.

    What I plan the function to do are:
    1) Divide the string into words
    2.1) Check against a database for words with unique cases (JohnData) so I can add into the database in the future, any word that comes up and is unique
    2.2) Check if a word is purely letters or has numbers; each have their own set of rules and filters
    2.3) For purely letters, run against another database that filters words like the, for, of etc. that are not to be put in a PROPER case
    3) Apply the correct case for each word
    4) Concatenate each word back into a string

    Currently, I'm stuck at number 1 because the loop won't work and I can't extract each word into one array slot.

    Hope I made myself clear. If you do not believe that I tried making this work with just basic Excel functions, just look at my 3,994 character formula. (Note, I had longer than this one.)
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-15-2020
    Location
    Philippines
    MS-Off Ver
    365
    Posts
    3

    Re: Unable to decipher what is wrong with the loop

    Thank you for that SPLIT function. Didn't know that exist.

    But I still want an answer as to why my loop is not working.
    For educational purposes. Hehehe

+ 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. [SOLVED] Help - Unable to figure out what is wrong with the code
    By goudavnash.b in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-24-2017, 03:29 AM
  2. [SOLVED] What's wrong with this loop?
    By DMA in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-15-2017, 05:18 AM
  3. Unable to LOOP
    By slxia1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-18-2014, 08:42 AM
  4. Loop through multiple files and call macros (but unable to loop)
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 12:04 PM
  5. What is wrong with this for loop?
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2014, 02:31 PM
  6. What's wrong with my loop ?
    By Grek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2006, 02:23 PM
  7. Loop Function unable to loop
    By Junior728 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2005, 06:05 AM

Tags for this Thread

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