+ Reply to Thread
Results 1 to 8 of 8

Include array reference into loop

  1. #1
    Registered User
    Join Date
    01-30-2014
    Location
    Montreal
    MS-Off Ver
    Excel 2011
    Posts
    6

    Include array reference into loop

    Hi !

    I'm kind of new into programming and I would need your help on this one... I have lot of buttons and they are all named by the same prefix "BtnRAP1P_" and a number instead of the underscore. If the value in the range ("L" & ___ ) (the underscore is the row value indicated by the position of the button) is "FAUX" then the button is not visible. I would like to introduce an Array to set the number to loop... and with what I have it crashes...

    Please Login or Register  to view this content.
    Thanks a lot !

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Include array reference into loop

    Please Login or Register  to view this content.
    it should read IF

  3. #3
    Registered User
    Join Date
    01-30-2014
    Location
    Montreal
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Include array reference into loop

    It sets me a red line when i remove the first I of IIF... but when I click debug, I see theat the value of i = 0 when it should be equal the array in my list...

    Please Login or Register  to view this content.
    Is it possible that the info doesn't communicate from the array to the shape TopLeftCell.Row request ?

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

    Re: Include array reference into loop

    If you want to refer to the values in the array while in the loop use Para(i).

    By the way, what is FAUX?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    01-30-2014
    Location
    Montreal
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Include array reference into loop

    FAUX means "false" in french...

    do you mean "refer to Para(i)" like this ?

    Please Login or Register  to view this content.
    In this way, it doesn't work actually...

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

    Re: Include array reference into loop

    What is the array actually for?

    As for FAUX, I thought that was what it was but I'm afraid VBA will only see it as an empty, undefined variable.

    If you want to base the visibility of the buttons based on a cell that contains either True or False you don't need the Iif, all you need is the cell value.

    Oh, almost forgot - how does the code not work?

  7. #7
    Registered User
    Join Date
    01-30-2014
    Location
    Montreal
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Include array reference into loop

    I should have specified... sorry about that...

    I tried to remove the IIF as you said and replacing it by a classic IF ELSE statement. It started to work like a charm !

    Please Login or Register  to view this content.
    I tried to put the FAUX between "" and my buttons stopped appering and desapearing as i wanted... weird a bit... but my excel is in french ant all the coding ids done in english so maybe this is why it accepts the FAUX as is...

    Anyway, thank for your help !

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

    Re: Include array reference into loop

    What happens if you add Option Explicit at the top of the module and then compile the code?

    By the way, this is what I meant about using the value from the cell.
    Please Login or Register  to view this content.

+ 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] Include 2 sheets in code loop?
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2013, 04:21 PM
  2. [SOLVED] Returning cell value in an array - instead of loop reference
    By danmack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 11:28 AM
  3. [SOLVED] Macro needs amendment to include loop
    By Marcel747400 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2012, 07:38 AM
  4. Change array to include new cells
    By nsorden in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2009, 06:10 AM
  5. MSDN should include a VBA reference.
    By spamania in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2005, 04:35 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