Unable to select individual cells when in vba break mode

davidam

Active Member
Joined
May 28, 2010
Messages
452
Hello All,
While constructing a procedure, I use 'Stop' in order to break execution and then step through subsequent lines in the program. Sometimes when I do this, the worksheet seems to anchor on one cell such that if I select another cell then an array, cornered by the original cell and the newly selected cell, will be selected. Has anyone else seen this? Any ideas on what causes it? When I type a different cell address in the cell address bar it returns to normal.
Thanks,
David
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
David

This behavior could be connected to the code you are running, can you post the code?
 

davidam

Active Member
Joined
May 28, 2010
Messages
452
Hi Norie,
The program is pretty big and I am not sure where I was when I last saw the behaviour. I can say without any doubt, however, that the code did not call for any selecting. (I have been well schooled on the folly of unnecessarily selecting ranges by this forum!).
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
Why are you selecting cells when code execution has been interrupted?
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,690
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

Why are you selecting cells when code execution has been interrupted?

That is the question I was just about to post.
 

davidam

Active Member
Joined
May 28, 2010
Messages
452
The code is acting on different parts of the sheet and I want to move around so that I can see what is happening...I know I could do this programically but it is quicker just to do it myself sometimes.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

If you want to move around the sheet use the scroll bars.
 

davidam

Active Member
Joined
May 28, 2010
Messages
452
I looked through the code and found one place where the code selected the 'anchor' cell. I wonder if VBA treats a cell selection like a shift-select, rather than just a select. If so it would account for this behavior, because a normal selection would be released as soon as another cell is selected.
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,690
Office Version
  1. 2010
Platform
  1. Windows
I looked through the code and found one place where the code selected the 'anchor' cell. I wonder if VBA treats a cell selection like a shift-select, rather than just a select. If so it would account for this behavior, because a normal selection would be released as soon as another cell is selected.
No, that is not how it works in VBA. If you did something like this in code, you could create the effect you are seeing though...

Rich (BB code):
' Select the anchor cell
Range("C5").Select
...
...  {later on in your code}
...
' Assuming H9 is a new cell to be selected
Range(Selection, Range("H9")).Select

Of course, without being able to see your actual code, all we can do is guess here.
 

davidam

Active Member
Joined
May 28, 2010
Messages
452
I think it is a bug, not the code. It happens occasionally and it is an annoyance more than anything. If I type a new cell address in the name bar, it stops doing it. Just wondered if others had seen it.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,712
Messages
5,597,719
Members
414,168
Latest member
Manapo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top