Consulting

Results 1 to 7 of 7

Thread: Excel TV Episode 1 Challenge Quesiton

  1. #1
    Moderator VBAX Regular
    Joined
    May 2010
    Location
    Dayton, OH
    Posts
    15
    Location

    Excel TV Episode 1 Challenge Quesiton

    This challenge question appeared on the first episode of Excel TV. While the winner has already been decided for last week, feel free to see if you can answer this riddle.

    What's wrong with this code?
    Click image for larger version. 

Name:	Episode 1.jpg 
Views:	158 
Size:	17.4 KB 
ID:	11383

    Do you think you know what the answer is? Feel free to post below.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    strUserList As Variant
    Last edited by SamT; 03-11-2014 at 11:20 PM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    another point. since it's a 0-based array, i would use: intFindUser = i + 1
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Redundant str..., bln..., integer as a data type, exit the loop when matched ... besides the obvious fault.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Option Base = Any
    '
    '
    '
    UserIndex = -1
    For i = LBound(UserList) to UBound(UserList)
       If UserList(i) = TargetUser Then
          UserIndex = i
          Exit Function
       End If
    Next i
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by SamT View Post
    Option Base = Any
    '
    '
    '
    UserIndex = -1
    For i = LBound(UserList) to UBound(UserList)
       If UserList(i) = TargetUser Then
          UserIndex = i
          Exit Function
       End If
    Next i
    Much better . And you ditched those ridiculous comments.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    function F_snb(targetuser,userlist)
        F_snb = Application.Match(targetuser, userlist, 0)
        If IsError(F_snb) Then F_snb=-1
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •