View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default application.inputbox

Very easy since a named range is just a string:

Sub rangerover2()
Dim r As Range
Dim s As String
On Error Resume Next
Set r = Nothing
s = Application.InputBox("Enter the name of a range", Type:=2)
Set r = Range(s)
MsgBox ("Address is: " & r.Address)
MsgBox ("Worksheet is: " & r.Parent.Name)
MsgBox ("Workbook is: " & r.Parent.Parent.Name)
r.Parent.Parent.Activate
r.Parent.Activate
r.Select
End Sub

--
Gary's Student


"Mannie G" wrote:

Hi "Gary's Student"

I saw your partent/grandparent post on the pause macro/ application.inputbox
discussion. I am using you code in an application to automate a quotation
from another workbook with several separte worksheets all with different
items and options.
Is it possible to change the selection method from "cell" to selecting
"named ranges" within the workbook?
--
Thanks

Mannie G


"Gary''s Student" wrote:

You can use parents and grandparents. This little macro allows the user to
select a range in any workbook and worksheet:


Sub rangerover()
Dim r As Range
On Error Resume Next
Set r = Nothing
Set r = Application.InputBox("Select a cell with the mouse", Type:=8)
MsgBox ("Address is: " & r.Address)
MsgBox ("Worksheet is: " & r.Parent.Name)
MsgBox ("Workbook is: " & r.Parent.Parent.Name)
r.Parent.Parent.Activate
r.Parent.Activate
r.Select
End Sub

--
Gary's Student


"Christmas May" wrote:

I'm attempting to have my VBA pause for the user to enter a range. I've used
application.inputbox(prompt:="Enter range", type:=8) which works great as
long as the user is planning to select a range in the current workbook.

Does anyone have a suggestion for allowing the user to select a range in a
different workbook?

Thanks in advance,

Christmas May