Don't move cursor when running macro

LFCdenmark

New Member
Joined
May 3, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a huge workbook with lots of columns. Some of them are hidden. I have made a simple macro that shows the hidden columns and another macro hiding them again.
In the 1st edition (of the macro) the cursor was send to cell A2 but now the users want the cursor to remain in the same cell it was in before the macro was executed.

Is it possible?
If so, how do I do that?

Here's the "show" macro:
Columns("T:AB").Select
Selection.EntireColumn.Hidden = False
Range("A2").Select

I have tried with these commands as well:
ActiveCell.Offset(1).Select
ActiveCell.Offset(-1).Select
but with no effect.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi & welcome to MrExcel.
How about
VBA Code:
Columns("T:AB").EntireColumn.Hidden = False
 
Upvote 0
Solution
Hi Fluff
You're my hero! ?
It works as intended and has now been implemented in the workbook mentioned.
Much appreciated ?
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,214
Members
453,024
Latest member
Wingit77

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