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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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
 
Upvote 0
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...
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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