+ Reply to Thread
Results 1 to 15 of 15

How to remove one additional loop

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    How to remove one additional loop

    Hi Guys,

    i have code:

    Please Login or Register  to view this content.
    and function:
    Please Login or Register  to view this content.
    what i am doing here is creating dictionary for t_loop table.
    For each row in this table i will be creating new workbook with data.

    Next i am creating dictionary for t_cource - this is my dictionary data.

    And problem is within looping within my dictionary (From for each vakeytop in DicLoop).

    For each variable in t_source Atributes column i am searching for matching string within each row in t_loop table.
    (If InStr(DicLoop(varkeytop), LandscapeVar) > 0 Then)
    example:

    For system in second column in t_source table i will check this if:
    If InStr(DicLoop(varkeytop), LandscapeVar) > 0 Then, --> here LandscapeVar is "System" so if statement will go further and find which system number should be taken (SystemVar)

    For object i will check this if also, and for Method i will check this if also.
    It is ok for ID1 in t_loop because i have 3 variables there inputed by user.

    Problem is with ID2 where there are only 2 variables: Object1 and System1.
    Here i want only run my if statement for System and Object from table t_source.
    I do not want to loop unnecessarily also for Method value here...

    How can i do it?
    Maybe it is better way then looping always for each value in t_source table?

    Please help,
    Jacek
    Attached Files Attached Files
    Last edited by jaryszek; 02-15-2018 at 08:17 AM.

  2. #2
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    anyone?

    Jacek

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    I have idea for this.

    I can loop somehow trough each item for each key.
    And if it will be matching with t_souce table i can take data from there.

    Problem is... how to loop through items within dictionary key?

    And if item1 from dictionary key1 = System1, how to find that in t_source there is in second column row with value System (not in first column but in second)
    I do not want to here have loops, only something like exists or maybe find (but find is slow i think).
    Create also dictionary there or maybe a class?

    Best,
    Jacek
    Last edited by jaryszek; 02-15-2018 at 12:45 PM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to remove one additional loop

    What are you trying to do actually?

    You have 2 tables and what is the relation between the 2?
    What is the outcome you expect?

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    Hi jindon,

    tables are related by text.
    In C column in t_source you have System, Object and Method strings and there are the same (almost) like inputed values in t_loop.
    System1 is referencing to System, Method5 is referencing to Methos and so on....

    I am looping through each row in t_loop table and mathing data from t_source.
    So what i want:
    1. For each value in t_loop, for example for Object2 i want to get easily access to all data in 2nd row within table in t_source (Topic2 and B2 in this case).

    Thank you for your hepl and support,
    Jacek

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to remove one additional loop

    So, no key column in t_loop and no exact match?

    Method2, Method5 should match to Method?

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    thank you jindon!

    what does it mean?

    Please Login or Register  to view this content.
    Here we have two loops like in my code.

    It is possible to elimate one loop here:

    Please Login or Register  to view this content.
    using maybe arraylist or something like that?
    To show exactly one match value and referencing row for it ?

    Best,
    Jacek

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to remove one additional loop

    Because your match rule is not EXACT match, it should loop through the keys in dictionary and find the LIKE value.

    eg

    System1 Like "System*" = True..etc.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    So "*" means & ?

    Thank you,
    jindon.

    Unfortunatelty there is no exact match here.

    Jacek

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to remove one additional loop

    You need to learn wild card characters.

    * = none or many characters
    ? = any one character
    # = one numerical character

    ### matches to 3 numerical characters like 123
    ###? matches to 3 numerical characters & one any character
    ###* matches to 3 characters and with or without any number of character(s).

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    thank you jindon,

    i know wildcars but here is not understandable for me:

    if (a(i, ii) <> "") * (a(i, ii)

    If System1 is different from "" AND (a(i, ii) Like ....

    Jacek

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to remove one additional loop

    I don't understand what you don't understand...

  13. #13
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    Here i know that you are checking:

    If (a(i, ii) <> "") * (a(i, ii) Like e & "*")

    If it is not empty and has value Like e do something

    aa you have () * () i am wondering what this star mean here?

    It is also wildcard?

    Jacek

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to remove one additional loop

    Ahhh, that means "And"

    equivalent to
    Please Login or Register  to view this content.
    In vba, True = -1, False = 0
    also evaluate 0 = False, other than 0 is True.

    (True) * (True) returns <>0 means True
    (True) * (False) returns 0 means False

    + means "Or"
    (True) + (False) returns -1 returns True.
    (False) + (False) returns 0, means False.

  15. #15
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to remove one additional loop

    Thank you !!

    Now fully undestood this

    Jacek

+ 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] Modfication of Existing Code for additional additional cells
    By thilag in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2016, 03:00 AM
  2. Remove Additional unwanted Rows
    By wysbob in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2015, 11:04 AM
  3. [SOLVED] VBA Need help with additional loop to copy range to different worksheet
    By Old-One in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2014, 05:19 PM
  4. Replies: 1
    Last Post: 02-06-2014, 03:00 PM
  5. Remove characters using Loop?
    By noidea_4 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-20-2012, 06:43 PM
  6. [SOLVED] How do I delete or remove additional blank pages of a worksheet?
    By Kim in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-27-2005, 04:05 PM
  7. sort a list/remove additional entries
    By Glowinafuse in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-23-2005, 06:06 PM

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