+ Reply to Thread
Results 1 to 11 of 11

explain how to use the window immediate in the VBA

  1. #1
    Registered User
    Join Date
    04-07-2015
    Location
    Vietnam
    MS-Off Ver
    Office 2013
    Posts
    89

    explain how to use the window immediate in the VBA

    Hello Guys!
    I really want to learn VBA, But I don't know how to fix mistake when I wrote the code in VBA.
    Example I have a file below.
    I try to correct my mistake in the file when I use the Immediate (Ctrl+G) and enter it. so that result is name in this file.
    But I can not fix mistake the code when I saw that.
    Please tell me how to use and how to fix again my mistake.
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: explain how to use the window immediate in the VBA

    As the filename is ...xlsx I assume there is no code ... so nothing to explain with your file.

    Generally, with Immediate Window, you can for instance call some procedures, or chceck specific values during code execution. Probably while code is paused because of breakpoint or msgbox popped out, etc.

    You can also assign some values to variables. But it is not the place to fix mistake in the the code. To manipulate code use simply Code window ( key <F7> ).
    Best Regards,

    Kaper

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: explain how to use the window immediate in the VBA

    The Immediate Window isn't really used to 'fix' code, though it can be used to debug by setting values, outputting values etc.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    04-07-2015
    Location
    Vietnam
    MS-Off Ver
    Office 2013
    Posts
    89

    Re: explain how to use the window immediate in the VBA

    Quote Originally Posted by Kaper View Post
    As the filename is ...xlsx I assume there is no code ... so nothing to explain with your file.

    Generally, with Immediate Window, you can for instance call some procedures, or chceck specific values during code execution. Probably while code is paused because of breakpoint or msgbox popped out, etc.

    You can also assign some values to variables. But it is not the place to fix mistake in the the code. To manipulate code use simply Code window ( key <F7> ).
    OH, I forgot save as xlsm, maybe I attached my file again.
    Does not that window immediate fix break code.
    If I write wrong a line code, How can I do with that code. If I can not remember how to write.
    example with my file below
    Attached Files Attached Files

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: explain how to use the window immediate in the VBA

    What exactly are you trying to fix?

    Is it the function TimTen?

  6. #6
    Registered User
    Join Date
    04-07-2015
    Location
    Vietnam
    MS-Off Ver
    Office 2013
    Posts
    89

    Re: explain how to use the window immediate in the VBA

    Quote Originally Posted by Norie View Post
    What exactly are you trying to fix?

    Is it the function TimTen?
    yes exactly, I want to correct funtion Timten.
    A4=TimTen(B2, B1:B29)
    but in the sheet 1 Timten=value? so I want to fix my code.
    When I try with this code
    ?TimTen(Range("E1").Value, Columns("B:B"))
    in the window immediate I saw result: Lư Th? H?o.
    So I dont know how to fix my code below monitor VBA.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: explain how to use the window immediate in the VBA

    What is the function TimTen meant to do?

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: explain how to use the window immediate in the VBA

    Try such modification:
    Please Login or Register  to view this content.
    to avoid testing when sRng Is already Nothing the condition on sRng.Address (which is invalid if sRng is Nothing).

  9. #9
    Registered User
    Join Date
    04-07-2015
    Location
    Vietnam
    MS-Off Ver
    Office 2013
    Posts
    89

    Re: explain how to use the window immediate in the VBA

    Quote Originally Posted by Kaper View Post
    Try such modification:
    Please Login or Register  to view this content.
    to avoid testing when sRng Is already Nothing the condition on sRng.Address (which is invalid if sRng is Nothing).
    well done. thank you very much.
    Exactly I am finding the result.
    But sometime I have many problem with my code, but I can not find the way to fix it.
    Please tell me how to write and fix break code?

  10. #10
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: explain how to use the window immediate in the VBA

    Here I set the breakpoint at first instruction, edited a cell with functin call and once code execution stopped I went instruction-by-instruction using <F8> key.

  11. #11
    Registered User
    Join Date
    04-07-2015
    Location
    Vietnam
    MS-Off Ver
    Office 2013
    Posts
    89

    Re: explain how to use the window immediate in the VBA

    Quote Originally Posted by Kaper View Post
    Here I set the breakpoint at first instruction, edited a cell with functin call and once code execution stopped I went instruction-by-instruction using <F8> key.
    I know, Thank you very much
    breakpoint by F8

+ 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 show both Project Explorer and Code window in the VB window?
    By m3atball in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2014, 07:22 PM
  2. [SOLVED] Different Screenupdating status in VBA Code Window than Immediate Window
    By ArnolddG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2014, 11:14 AM
  3. Replies: 2
    Last Post: 09-11-2013, 04:35 AM
  4. [SOLVED] Module works on window XP but not window 7 (using same Excel 2007)
    By wongwlv in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-23-2012, 12:32 AM
  5. Replies: 4
    Last Post: 02-17-2011, 08:29 AM
  6. [SOLVED] In Excel - how to delete new window created from window on tool ba
    By Doug in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-20-2006, 04:25 PM
  7. [SOLVED] How do I undo the Excel, Window Menu, New Window command
    By OLDFANG in forum Excel General
    Replies: 2
    Last Post: 03-17-2006, 01:35 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