problem with excel vba immediate window

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
LVL 27
ProfessorJimJamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
The ImmediateWindow display will only work if you are at a breakpoint in the test sub.
0
Martin LissOlder than dirtCommented:
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
ProfessorJimJamAuthor Commented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

ProfessorJimJamAuthor Commented:
my immediate window returns if i type ?activecell.value for example

but why it does not return when i put ? finalrow1
0
Martin LissOlder than dirtCommented:
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
ProfessorJimJamAuthor Commented:
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
Martin LissOlder than dirtCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ProfessorJimJamAuthor Commented:
Thank you. you are indeed Genius
0
Martin LissOlder than dirtCommented:
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
Martin LissOlder than dirtCommented:
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
ProfessorJimJamAuthor Commented:
thank you. Marty  i am already a follower of your profile. i found very useful article there.
thank you again for your contribution
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.