Heres the proble...

  • Thread starter Thread starter Edwin Merced
  • Start date Start date
E

Edwin Merced

I need to open an uinput box that should ask the user to type in a range.
When the user types the range and clicls a button the range shoud appear
selected. How difficult is this??
 
Edwin Merced said:
I need to open an uinput box that should ask the user to type in a range.
When the user types the range and clicls a button the range shoud appear
selected. How difficult is this??
Doesn't sound very difficult, but I wonder what's the idea here ? I mean
you can type the range directly into the "range selection box" in an Excel
worksheet at the upper left corner.

Do you just want to add some special control into your worksheet (at
application level)?

Kaj B.
 
This will open an InputBox and allow them to select a range, rather
than typing the range in the InputBox.

Sub SelectRange()
Dim rngR As Range

On Error Resume Next
Set rngR = Application.InputBox(Prompt:="Select a range.", _
Type:=8)
If rngR Is Nothing Then MsgBox "Did you select a range?"
On Error GoTo 0
rngR.Select
End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
 
Edwin,

Try something like the following:

Dim Rng As Range
On Error Resume Next
Set Rng = Application.InputBox(prompt:="Select a range", Type:=8)
On Error GoTo 0
If Not Rng Is Nothing Then
Rng.Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Hi Edwin,

Here's one way to do it:

On Error Resume Next
Application.InputBox("msg","title","A1",,,,,8).Select
On Error Goto 0

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Dim rng as Range
On Error Resume Next
set rng = Application.InputBox("Select a range with your mouse", type:=8)
On Error goto 0
if not rng is nothing then
rng.Select
else
msgbox "You cancelled"
End if

Note that Application.InputBox is not the same as InputBox alone. The
latter is the vba inputbox and the former the Excel inputbox.
 
OK but afterwards how do I instruct to graph what has been selected with the
Input Box?
 
A very simple example:

Sub Macro1()

Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox("Select a range with your mouse", Type:=8)
On Error GoTo 0
If Not rng Is Nothing Then
rng.Select
Else
MsgBox "You cancelled"
Exit Sub
End If

Charts.Add
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=rng, PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=rng.parent.name
ActiveChart.HasTitle = False
End Sub
 
A graph on a worksheet is a ChartObject which has top, left, height and
width attributes, so you can set those to size it.

With Activesheet.ChartObjects(1)
.top = 20
.Left = 20
.Height = 100
.Width = 175
End With
 
THANX THANX THANX!!! You guys are great!


Tom Ogilvy said:
A graph on a worksheet is a ChartObject which has top, left, height and
width attributes, so you can set those to size it.

With Activesheet.ChartObjects(1)
.top = 20
.Left = 20
.Height = 100
.Width = 175
End With
 
Back
Top