Get Range, that user marked
How can I get the Range, a user had marked bevor calling the macro?
..Range(??? ActiveCell .... ??? ) Thanks, Ben |
Get Range, that user marked
Hi Ben
It's Selection : Sub test() Dim Rng As Range Set Rng = Selection MsgBox Rng.Address & " on " & Rng.Parent.Name & _ Chr(10) & Rng.Count & " cells" End Sub HTH. Best wishes Harald "Ben" skrev i melding ... How can I get the Range, a user had marked bevor calling the macro? .Range(??? ActiveCell .... ??? ) Thanks, Ben |
Get Range, that user marked
of course that fails if the selection is not a range.. if not TypeOf selection Is Range then MsgBox "ouch" else set rng=Selection end if on the other hand... Activewindow.RangeSelection will work.. but I never see it used.. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Harald Staff wrote : Hi Ben It's Selection : Sub test() Dim Rng As Range Set Rng = Selection MsgBox Rng.Address & " on " & Rng.Parent.Name & _ Chr(10) & Rng.Count & " cells" End Sub HTH. Best wishes Harald "Ben" skrev i melding ... How can I get the Range, a user had marked bevor calling the macro? .Range(??? ActiveCell .... ??? ) Thanks, Ben |
Get Range, that user marked
It works very well. Thanks!
Ben "keepITcool" schrieb: of course that fails if the selection is not a range.. if not TypeOf selection Is Range then MsgBox "ouch" else set rng=Selection end if on the other hand... Activewindow.RangeSelection will work.. but I never see it used.. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Harald Staff wrote : Hi Ben It's Selection : Sub test() Dim Rng As Range Set Rng = Selection MsgBox Rng.Address & " on " & Rng.Parent.Name & _ Chr(10) & Rng.Count & " cells" End Sub HTH. Best wishes Harald "Ben" skrev i melding ... How can I get the Range, a user had marked bevor calling the macro? .Range(??? ActiveCell .... ??? ) Thanks, Ben |
Get Range, that user marked
Actually,
Activewindow.RangeSelection gives back a range regardless what is selected. It will give the last selected range if currently no range is selected (when e.g. a shape is selected) This can be very handy or very annoying depending on what you want. Dm Unseen |
Get Range, that user marked
in a scenario like "select range, press button" it's indispensable... Sub DoButton() MsgBox ActiveWindow.RangeSelection.Address End Sub -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam DM Unseen wrote : Actually, Activewindow.RangeSelection gives back a range regardless what is selected. It will give the last selected range if currently no range is selected (when e.g. a shape is selected) This can be very handy or very annoying depending on what you want. Dm Unseen |
All times are GMT +1. The time now is 12:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com