Consulting

Results 1 to 3 of 3

Thread: Solved: Next without For error

  1. #1

    Solved: Next without For error

    Hi,

    I'm getting a compile error - 'Next without For' for the following code. I don't understand why.

    [vba]Sub test()

    For Counter = 7 To 1000

    Set curCell = Worksheets("Sheet1").Cells(Counter, 4)
    If curCell.Value = "Yes" Then
    curCell.Offset(0, 1).Value = "n/a"

    Next Counter

    End Sub[/vba]

    Any ideas?

    Thanks.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    End If
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    or put[VBA]If curCell.Value = "Yes" Then
    curCell.Offset(0, 1).Value = "n/a"
    [/VBA]all on the same line:[VBA]If curCell.Value = "Yes" Then curCell.Offset(0, 1).Value = "n/a"
    [/VBA]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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