Should be Easy. Need help on selecting range.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
I want the selection to show cross way.
I have two lines here: i want them to be selected in one go and not one by one.
Code:
[FONT=Courier New]Range(Cells(rw, "A"), Cells(rw, "G")).Select
Range(Cells(1, cl), Cells(10, cl)).Select[/FONT]

Current code:
Code:
[/FONT]
[FONT=Courier New]Option Explicit
Sub hilightRowsAndColumns()
Dim cl, rw
cl = Selection.Column
rw = Selection.Row
Range(Cells(rw, "A"), Cells(rw, "G")).Select
Range(Cells(1, cl), Cells(10, cl)).Select
End Sub

Thanks for Helping!:)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,449
Code:
Sub hilightRowsAndColumns()
    Dim cl As Long, rw As Long
    cl = Selection.Column
    rw = Selection.Row
    Union(Range(Cells(rw, "A"), Cells(rw, "G")), Range(Cells(1, cl), Cells(10, cl))).Select
End Sub
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Alpha, perfect. can you please make one more change?

I want activecell/selection [the cell that was selected before running code...] cell be activated from the selection i made...
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,449
Code:
Sub hilightRowsAndColumns()

    Dim c As Range
    
    Set c = ActiveCell
    
    Union(c, _
          Range(Cells(c.Row, "A"), Cells(c.Row, "G")), _
          Range(Cells(1, c.Column), Cells(10, c.Column))).Select
          
    c.Activate
    
End Sub
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,598
Messages
5,832,645
Members
430,150
Latest member
amitk1

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
Top