+ Reply to Thread
Results 1 to 10 of 10

Debug single line of code

  1. #1
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Debug single line of code

    I can't seem to figure out the issue here, I keep getting the Range_Global_failed error. Trying to make this cut/paste code as short as possible:
    Please Login or Register  to view this content.
    Any suggestions?

  2. #2
    Forum Contributor
    Join Date
    02-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    272

    Re: Debug single line of code

    Remove:

    Please Login or Register  to view this content.
    Please consider adding a * if I helped

  3. #3
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Debug single line of code

    That segment of code is the Paste destination. What is the proper way of writing this?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Debug single line of code

    Paste
    is missing from the code.

  5. #5
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Debug single line of code

    Okay, thank you. My variable (count1) is in a different subroutine. How do I declare it in such a way that it's value can be used in this line of code? (public variable?)

  6. #6
    Forum Contributor
    Join Date
    02-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    272

    Re: Debug single line of code

    Something like this :

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Debug single line of code

    Thanks, wfm007. I found an additional problem to be that my variable count1 (from the previous subroutine) is empty. It should be a positive integer, but once that previous sub ends the value is not retained. How might I allow this subsequent subroutine to access that value?

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Debug single line of code

    If you trying to access a variable from another sub, you need to declare that variable as global

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Debug single line of code

    This might help you

    In VBA there are three levels of scope.

    Local: the variable is declared inside a Sub or Function, using the Dim or Static keyword and is only availible inside that procedure.


    Code:
    Please Login or Register  to view this content.
    ...
    Module-wide: the variable is declared at the beginning of the module with the Dim keyword. it is available ot all procedures in that module, but not to procedures in other modules


    Code:
    Please Login or Register  to view this content.
    ...
    Public - the variable is declared at the beginning of a normal module with the Public key word. It is avaliable to all procedures is all modules of that project. (Variables declared with Public in Class, Userform and Object code modules have specialized meanings.)


    Code:
    Please Login or Register  to view this content.
    ...
    Global is not a VBA reserved word. There are no (uppercase) Global variables in VBA. "global" is a term in the meta-language of programming, not in the programming language VBA

  10. #10
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Debug single line of code

    Wow, exactly what I needed. Thanks a ton AB33

+ 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. [SOLVED] how to write three macro code in single line ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2013, 03:29 AM
  2. A single line of code i cant work out...
    By PhishTaco in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2012, 03:49 AM
  3. how do you execute single line of code?
    By honestlylion in forum Excel General
    Replies: 2
    Last Post: 02-24-2006, 11:40 AM
  4. How show value of variable by mouse-over in debug single step mode
    By Chet Shannon in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-06-2006, 11:35 AM
  5. [SOLVED] How show value of variable in single step debug mode?
    By Chet Shannon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2005, 03:00 AM

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