Selecting a range, and naming it, within a macro

G

Guest

Guest
I have a macro which copies a column of data (variable length) to a certain part of a spreadsheet. I want to select the range and apply a name to it. When I use the Select Current Region option, it is recorded in the macro with the precise cell references, which is no use when running the macro for a list of a different length. Also, it cannot record the keystrokes of holding the tab down and pressing END.
Can anyone help?
Thanks, Andrew
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try recording the Ctrl-* combination. Alternatively, use the VBA code Activecell.CurrentRegion.Name="Any text"

Marc
 
Upvote 0
On 2002-03-15 01:52, Anonymous wrote:
Try recording the Ctrl-* combination. Alternatively, use the VBA code Activecell.CurrentRegion.Name="Any text"

Marc

Hi Marc
The VBA code worked beautifully. Many thanks.
Incidentally, I didn't understand what you meant by "Try recording the Ctrl-* combination" - something about creating an outline?

Many thanks again
Andrew
 
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,297
Members
448,564
Latest member
ED38

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