Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Get Range, that user marked

How can I get the Range, a user had marked bevor calling the macro?
..Range(??? ActiveCell .... ??? )

Thanks,
Ben
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Marking cell; totaling all # between marked cell & next marked cel Marley Excel Worksheet Functions 4 February 26th 09 01:26 AM
Counting Marked Cells Fred Atkinson Excel Worksheet Functions 3 December 8th 06 06:19 PM
marked column lucas Excel Discussion (Misc queries) 1 February 7th 06 06:33 PM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
use vb to delete marked rows Phil Excel Programming 5 July 16th 04 09:19 PM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"