ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing range to a Sub (https://www.excelbanter.com/excel-programming/376939-passing-range-sub.html)

Barb Reinhardt

Passing range to a Sub
 
I've got a worksheet_selection change event and under certain circumstances,
I'd like to call another procedure. I need to pass the TARGET range to that
other procedure. How do I do this? I've tried a couple of things that
don't seem to work.

Thanks

RB Smissaert

Passing range to a Sub
 
Sub Test1()

Dim rng As Range

Set rng = Range(Cells(1), Cells(5, 5))

Test2 rng

End Sub


Sub Test2(rng As Range)

MsgBox rng.Cells.Count

End Sub


RBS


"Barb Reinhardt" wrote in message
...
I've got a worksheet_selection change event and under certain
circumstances,
I'd like to call another procedure. I need to pass the TARGET range to
that
other procedure. How do I do this? I've tried a couple of things that
don't seem to work.

Thanks



RB Smissaert

Passing range to a Sub
 
And it works just the same in worksheet event:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Test2 Target

End Sub

RBS


"Barb Reinhardt" wrote in message
...
I've got a worksheet_selection change event and under certain
circumstances,
I'd like to call another procedure. I need to pass the TARGET range to
that
other procedure. How do I do this? I've tried a couple of things that
don't seem to work.

Thanks




All times are GMT +1. The time now is 05:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com