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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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,214,982
Messages
6,122,575
Members
449,089
Latest member
Motoracer88

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