Results 1 to 6 of 6

for loop can not test for upper limit

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    for loop can not test for upper limit

    Hi,

    It must be getting late or something but for some reason i am having trouble with a simple for-loop.

    The for loop goes from 1 to 7.

    When x=7 i want to display a message to screen.........but for some reason i never see the message.......here is the code.........what am i missing?



    Sub test()
    
    num_proj = 7
    
    For x = 1 To num_proj
    
        If x = num_proj Then MsgBox ("hlkjl")
        If x = 1 Then MsgBox ("1")
        If x = 2 Then MsgBox ("2")
        If x = 3 Then MsgBox ("3")
        If x = 4 Then MsgBox ("4")
        If x = 5 Then MsgBox ("5")
        If x = 6 Then MsgBox ("6")
        If x = 7 Then MsgBox ("7")
    
    
        If x = 1 Then
            formula_string = "=Sum(C" & (22 * x + 8)
           
        ElseIf x > 1 Then
            formula_string = formula_string & " , C" & (22 * x + 8)
            
        ElseIf x = num_proj Then
            'formula_string = formula_string & " , C" & (22 * x + 8) & ")" & "lkjlkjl"
           MsgBox ("in here")
           
        End If
    
    Next x
    
    
    End Sub
    Attached Files Attached Files
    Last edited by welchs101; 01-04-2013 at 09:42 AM.

Thread Information

Users Browsing this Thread

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

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