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!:)
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,275
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,275
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:

Watch MrExcel Video

Forum statistics

Threads
1,108,630
Messages
5,523,991
Members
409,554
Latest member
denistrevisan

This Week's Hot Topics

Top