VBA MACROS - keyboard shortcut range code

Sulrc

New Member
Joined
Mar 23, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I’m not sure this is the best way to go about it..

But I need code to get a specified range in a macro. The range is variable .. so I’m trying to use keyboard shortcuts like “ctrl + home” and “ctrl + end” to get the correct range.

The problem is when I start let’s say at the bottom right cell of my range and click “ctrl + home” this selects and brings my range all the way to the top. Then I click “shift + cell (down 5rows)” for the correct range.

My problem is .. it works when I manually press these keys on the keyboard. When try this type of code in a macro .. I think it uses the top left most as my active cell and not my most bottom right cell as active cell.

So essentially I have not been able to figure out a right way to make a macro that selects the specific “range” I would like which is variable. But I am able to choose the correct range when I use keyboard shortcuts. I cannot just choose a specific range because the range does change.

Thanks for any feedback and reading through !!! Please comment if you have any further questions.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi,
From any cell in your ... "specified range" , as you say it, use .CurrentRegion
 
Upvote 0
Hi,
From any cell in your ... "specified range" , as you say it, use .CurrentRegion
Thank you for your reply! I will try this out and try to paste some code for reference. I am quite new to macros!
 
Upvote 0
Do not hesitate to get back to the Forum with the results of your tests ;)
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,279
Members
449,094
Latest member
GoToLeep

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