+ Reply to Thread
Results 1 to 4 of 4

Compile error Variable not defined...?

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    491

    Compile error Variable not defined...?

    I am new to VBA and I am trying to follow this tutorial (see link)

    http://www.homeandlearn.org/a_string_exercise.html

    I entered the code as such...

    Sub changeblock()

    Dim productcode As String
    Dim letters As String
    Dim numbers As String
    Dim newcode As String

    productcode = "PD-23-23-45"
    letters = Left(productcode, 2) & c
    numbers = Mid(productcode, 3)
    newcode = letters & numbers
    MsgBox newcode

    End Sub


    I get the compile error variable not defined message.

    What the heck is going on here?

    -Thanks

  2. #2
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: Compile error Variable not defined...?

    See this line
    Please Login or Register  to view this content.
    What's that c? Is it a mistake, or you missed something in your code?

  3. #3
    Forum Contributor
    Join Date
    03-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    491

    Re: Compile error Variable not defined...?

    Disregard, I forgot to put quotes around the C

    rookie mistake...gulp.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Compile error Variable not defined...?

    swade730,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Compile error: Variable not defined
    By jrpuig1977 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-16-2014, 06:55 PM
  2. [SOLVED] Compile Error: Variable Not Defined
    By Limitedtimeonearth in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-03-2013, 03:07 PM
  3. Compile error on variable (not defined)
    By mqdias in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2007, 06:47 AM
  4. Compile error: Variable not defined
    By radion in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2007, 05:31 PM
  5. Compile error, variable not defined
    By davegb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2005, 12:06 PM

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