-
Calling a Worksheet_SelectionChange Subroutine
i would like to call this sub from another macro to have it work in a specific sheet in the workbook. this is the code i have that works in whatever sheet i put it in (highlights active row+col), but when i try to call it from another macro, i don't know what argument to pass to get it to work in the active sheet (or whatever sheet i want). the sheet i want it to run in is user generated, so the name will change depending on "i"
[vba]Call Worksheet_SelectionChange "number " & i & " sheet"[/vba]
this call method doesn't seem to work....is this the "target" parameter or is it something else? i've tried passing "ActiveSheet" as well to no avail.
here's the main code...
[vba]Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim RngRow As Range
Dim RngCol As Range
Dim RngFinal As Range
Dim Row As Long
Dim Col As Long
Cells.Interior.ColorIndex = xlNone
Row = Target.Row
Col = Target.Column
Set RngRow = Range("A" & Row, Target)
Set RngCol = Range(Cells(7, Col), Target)
Set RngFinal = Union(RngRow, RngCol)
RngFinal.Interior.ColorIndex = 6
End Sub[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules