Solved

problem with excel vba immediate window

Posted on 2014-09-22
11
215 Views
Last Modified: 2014-09-22
my immediate window does not work suddenly. any idea why it was working before but after running the macro once it does not return the Finalrow number in immediate window

when i put print FinalRow   nothing returns
 also i tried  with ?FinalRow

however when i put the msgbox then it works.

 suddenly it stopped working.  is there somthign i did wrong?

please see attached file
Book1.xlsm
0
Comment
Question by:ProfessorJimJam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40337126
The ImmediateWindow display will only work if you are at a breakpoint in the test sub.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40337151
If you were to define FinalRow (IMO you should define ALL variables) like this

Option Explicit

Dim FinalRow As Long ' Private would be better than Dim

Open in new window


then you could see the value at any breakpoint.
0
 
LVL 26

Author Comment

by:ProfessorJimJam
ID: 40337183
in this case can you see the attached file. why it does not stop at row 120 and it continues the formula to the million of rows. the vba does not stop where it should stop at the finalrow1
VBA-prob.xlsm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Author Comment

by:ProfessorJimJam
ID: 40337188
my immediate window returns if i type ?activecell.value for example

but why it does not return when i put ? finalrow1
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40337214
Because you haven't defined FinalRow, so after sub test it doesn't exist, whereas activecell always exists because it's built into Excel.
0
 
LVL 26

Author Comment

by:ProfessorJimJam
ID: 40337222
MartinLiss,
can you please look into the file i uploaded. and help me with the issue where the formula does not stop at 120th row .

thanks.
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40337242
In that file you have this line

Do Until main.Cells(introw, 1) = finalrow1

which says "Do this process until the value in column A = 120" and it never will be "120" so it never stops. Try this instead

Do Until intRow = finalrow1
0
 
LVL 26

Author Closing Comment

by:ProfessorJimJam
ID: 40337257
Thank you. you are indeed Genius
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40337260
Thank you. you are indeed Genius
Thanks but not really. I'm just an old man with a lot of experience. In any case you're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40337264
BTW in my profile you'll see a link to an article I wrote on debugging. Take a look at it since it may help you with problems like this one.
0
 
LVL 26

Author Comment

by:ProfessorJimJam
ID: 40337266
thank you. Marty  i am already a follower of your profile. i found very useful article there.
thank you again for your contribution
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question