Why is this happening?

Bub_the_Zombie

Board Regular
Joined
Nov 1, 2016
Messages
53
Hey everyone I have a piece of vba code that is very long and works on several sheets. Because of the selecting ranges for copy and pasting I added a command to select a single cell after the commands were done so the blue highlight selection field would go away. For some reason it works on every page except one, why is that?

WS works, WS2 does not

Code:
  WS.Range("N1").Select
  WS2.Range("N1").Select
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Because WS is already selected, WS.Range("N1").Select works, but WS2 is NOT selected, that is why WS2.Range("N1").Select won't work...
You need to select the worksheet before selecting cells:
Code:
WS.Select
WS.Range("N1").Select
WS2.Select
WS2.Range("N1").Select
 
Upvote 0
I wonder if these two lines come together? If yes, then what's the point of selecting cells? Why would you select cells when you can avoid this unnecessary operation (which also slows down code execution speed).
 
Upvote 0
I added the cell selection command because on every page of the worksheet the last range copied was highlighted in blue, and it was annoying. Had to keep clicking a random cell on each page to remove the highlight from the range.

The lines are placed back to back, exactly written above.
 
Upvote 0

Forum statistics

Threads
1,203,396
Messages
6,055,158
Members
444,766
Latest member
bryandaniel5

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
Back
Top