Consulting

Results 1 to 4 of 4

Thread: Beginners question

  1. #1

    Beginners question

    Hello, I am "taking" a course that appeared on the Web but in the first lesson I've a problem.
    The instruction reads were to copy:

    Example 2.
    Sub Example2()
    For x = 1 To 5
          Cells(x, 3).Select 
          Selection.Vaue = x + 1 
    Next x 
    End Sub
    and then with the cursor somewhere within the macro press F5.

    This generates a dialog box with Compile Error Variable Not Defined.

    Was something left out of the instructions or have I gummed up my software?

    I'm a rank beginner so all help will be appreciated.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You probably have Option Explicit at the top of the macro. Also there is no need to select a range to change the value. Try this instead.

    Sub Example2() 
    Dim x As Long
    For x = 1 To 5 
            Cells(x, 3).Value = x + 1 
        Next x 
    End Sub

  3. #3
    VBAX Regular MUSASHI's Avatar
    Joined
    Oct 2004
    Location
    Corpus Christi, Texas (Very South)
    Posts
    44
    .vaue?

    .value

  4. #4
    Thank 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
  •