Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

Stepping through like F5

Hi guys,

I have some code below, i like to step through bit by bit to test.

When i press F8 on the below code, it is running striaght through it, how/why is this?! I am not using F5, its F8....

Any help would be appreciated!

Thanks
SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seamus2626

ASKER

But i shouidnt need to set a breakpoint, if that wasnt opening a file, i could step through code w/o setting a breakpoint.....
You didn't actually show the code so why don't you do that now.
Sorry Martin

Sub DoingTheWork()

Workbooks.Open Filename:= _
        "A:\Horis Info\ME_denniss_Project\whynee Downloads\CurrentMonth.xlsx"


Sheets("Incountry").Select


       
    Cells.Select
    With Selection
        .WrapText = False
        .MergeCells = False
    End With
OK I don't see anything unusual so why don't you try putting a breakpoint at the Workbooks.Open line.
Or just put your cursor somewhere in the sub and press F8.
I can work around it by putting the breakpoint in at sheets, but i want to know its runnning through the code without my permission!!
Sorry but I'm not sure what you mean. Can you list, step by step, what you are doing and what you expect to happen?
So, i expect to go into the sub and press F8, then i expect the cursor to move through the first line of code, then when i press F8 again, i expect it to move through the next, and so on, i dont want it to run through the entire script as if i was pressing F5

Thanks
I guess I don't know why it's doing that. Do you perhaps have f8 assigned to something else? What happens if you press the "Step into" menu item?
Avatar of Norie
Norie

Exactly what part of the code is this happening on?

Also, how is the code being run/triggered?
So, F8 works fine for stepping through all my code, its just when i have the code

Workbooks.Open Filename:= _
        "A:\Horis Info\ME_denniss_Project\whynee Downloads\CurrentMonth.xlsx"



Thats the problem, when im opening a file, it triggers the code off to run through the rest off the sub

If my sub was

Sub test

Msgbox "hello"
Msbox "hello"
[A1].slect

End sub

F8 would step through each line perfectly
Probably because the other workbook becomes active.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the info guys!
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