SELECT AN AREA USING MACO

Mike E Golding

Board Regular
Joined
Mar 7, 2002
Messages
71
From within a macro I need to reproduce the action of pressing
and holding Shift, then pressing End, Down Arrow, End, Right Arrow, then
releasing the shift key. I can do the first half (i.e. up to and including
the Down Arrow) using:

Range(Selection, Selection.End(xlDown)).Select

But how do I now add to the selection the right hand area?

Regards,
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi Mike,

A couple of ideas:
Code:
Sub Test()
    Dim rng As Range
    
    Set rng = Range(Selection, Selection.End(xlDown))
    Set rng = Application.Union(rng, Range(rng, Selection.End(xlToRight)))
    rng.Select
    
End Sub

Sub Test2()
    Dim lRow As Long, iCol As Integer, rng As Range
    
    lRow = Selection.End(xlDown).Row
    iCol = Selection.End(xlToRight).Column
    Set rng = Range(Selection, Cells(lRow, iCol))
    rng.Select
    
End Sub
HTH
 
Upvote 0

Forum statistics

Threads
1,203,666
Messages
6,056,640
Members
444,879
Latest member
suzndush

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