ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control for Range (https://www.excelbanter.com/excel-programming/284390-re-control-range.html)

Keith Willshaw

Control for Range
 

"Syed Zeeshan Haider" wrote in
message ...
Hello Experts,
I have Excel 97 Pro on Win98SE.

I guess there is a control available in VBA for Excel (similar to Formula
Palette), which we can use to let the user chose a range for macro. I am
attaching the image (ctl.bmp, 886 bytes) of its typical recognition. My
questions a
What is the name of this control?
How to appear it?

A macro, written by me, needs a range for running but the user has to type
the range in InputBox which is not very wise to me.


If you use the type argument with input box you can select
a range using the mouse

Dim temp_range as Range
Set temp_range = Application.InputBox(prompt:="Select Range for Operation",
Type:=8)

Keith



Syed Zeeshan Haider[_4_]

Control for Range
 
"Keith Willshaw" wrote in message ...

If you use the type argument with input box you can select
a range using the mouse

Dim temp_range as Range
Set temp_range = Application.InputBox(prompt:="Select Range for

Operation",
Type:=8)


Thanks! It is a good replacment of RefEdit for certain occasioans.

There is a problem. When I click Cancel button it raises error 424, that is
"Object required".

How can I get rid of this error?

Thank you



Tom Ogilvy

Control for Range
 
You have to write your code to properly handle the cancel

Dim temp_range as Range
On Error Resume Next
Set temp_range = Application.InputBox(prompt:= _
"Select Range for Operation",Type:=8)
On Error goto 0
if temp_range is nothing then
' user hit cancel
else
temp_range.Select
End if

The last several lines are just illustrative of taking action - you can
program whatever is appropriate in your situation.

--
Regards,
Tom Ogilvy


"Syed Zeeshan Haider" wrote in
message ...
"Keith Willshaw" wrote in message ...

If you use the type argument with input box you can select
a range using the mouse

Dim temp_range as Range
Set temp_range = Application.InputBox(prompt:="Select Range for

Operation",
Type:=8)


Thanks! It is a good replacment of RefEdit for certain occasioans.

There is a problem. When I click Cancel button it raises error 424, that

is
"Object required".

How can I get rid of this error?

Thank you






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

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