Results 1 to 9 of 9

For without Next error

Threaded View

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    5

    For without Next error

    Hi,

    I'm very new to VBA so this must be a very basic question. I've been trying for about 10 hours to get a simple Loop correct, which includes an If condition, but keeps returning an error saying 'For without Next'. Any help would be appreciated. Code below:
    Private Sub Country()
    
    i = 2
    
    Do Until i = 42000
    
    For j = 2 To 250
    
    If Application.WorksheetFunction.IsError(Application.WorksheetFunction.Search(Cells(j, 9), Cells(i, 2))) = True Then
    
    Next j
    
    Else: Cells(i, 3) = Cells(j, 9)
    
    End If
    
    Loop
    
    End Sub
    Last edited by vlady; 04-12-2013 at 01:06 AM. Reason: code tags

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