+ Reply to Thread
Results 1 to 9 of 9

Identifier under cursor is not recognized error

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Identifier under cursor is not recognized error

    Confusion.jpg

    I am new to VB and have little experience coding.

    I have attached the image of what error is highlighting and how it is affecting me.


    In the sub, I have visual basic menus popping up asking yes or no questions. If answered yes, Alt1 = "1", if answered no, Alt1 = "0".
    Then I'm referencing to those variables to set values to the variables shown. I just don't know what I'm doing wrong.

    Thank you for any help offered

  2. #2
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Identifier under cursor is not recognized error

    Is this because 'Dim' cannot reference a value in a cell? Is there a way to have a variable in the code reference a numeric value of a specific cell?
    ie: I was the variable Alt1Lab to equal the value of cell D17 of sheet 'Bid Summary'.
    Thank you for the help

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Identifier under cursor is not recognized error

    Alt1Lab is dimensioned as Long (an integer). The line indicated is trying to set a string value "'Bid Summary'!D54" to that variable.

    You need to dimension Alt1Lab as a String not as Long.

    Or are you trying to assign Alt1Lab the value in the cell 'Bid Summary'!D54?
    If that is your goal, you should Dim Alt1Lab as Variant and use the line
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Identifier under cursor is not recognized error

    That was reasonably helpful! Thank you - the error has gone away, however, now I have a different issue. I did the following:
    - switched the variables to Variant instead of Long
    - Referenced them as suggested using.Value

    Now I have a section of code that is trying to use those values in a summation and on the sheet, there is a #Name? because it is adding a value and 'Alt1Lab'.
    Please Login or Register  to view this content.
    After the macro runs, the cell states ='Bid Summary'!D17+Alt1Lab+Alt2Lab+Alt3Lab+Alt4Lab+Alt5Lab and the #NAME? code appears.

    Any other suggestions?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Identifier under cursor is not recognized error

    Since Alt1Lab is always coming from the same cell and (presumably) that is also true of alt2-5Lab, you could replace the variable names in the formula with the cell addresses from whence they come.

    Or
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Identifier under cursor is not recognized error

    I have changed the code to you recommendation however the #NAME? Error still remains although the resultant in the cell is different.
    It now shows the following:
    ='Bid Summary'!D1714163.492

    I cannot reference the cell directly because it doesn't always apply (unless the user clicks on the 'yes' button when prompted with the yes or no question. I thought I might be able to set up several different cases which would reference the specific cells and choose the appropriate cells when necessary but there are over 100 possible combinations of yes/no and that would take an enormous amount of code.
    Any other suggestions?

    Here is what I currently have:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Identifier under cursor is not recognized error

    Just guessing what you're trying to do,

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Identifier under cursor is not recognized error

    What a guess. You got it perfect. Thank you very much. I really appreciate the help from both of you. Reputation Added.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Identifier under cursor is not recognized error

    You're welcome, ahilty.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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