ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   user input of a range of cells (https://www.excelbanter.com/excel-programming/370059-user-input-range-cells.html)

naz

user input of a range of cells
 
How do I initiate a user input of a range of cells after clicking a
visual object? I want the program to pause whilst the user selects a
range of cells on the worksheet whcih will be used later to input a
file directory.

I appreciate any help.

Thanks Naim.


Mark

user input of a range of cells
 

naz wrote:
How do I initiate a user input of a range of cells after clicking a
visual object? I want the program to pause whilst the user selects a
range of cells on the worksheet whcih will be used later to input a
file directory.

I appreciate any help.

Thanks Naim.


Here is an example to test. Enter the following into any worksheet
code module you want and then simply double click that worksheet to run
the test. If this does what you want just take the code out of the
worksheet and adapt it to your needs.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Dim Answer As String
Dim ProcRng As Range

Cancel = True
On Error GoTo Handler

GetAddress:
Answer = InputBox("Please enter the range of cells to be
processed:")
Set ProcRng = Range(Answer)
ProcRng.Select
MsgBox "You have selected the range(" & ProcRng.Address & ") for
use in this example."
Target.Select
Exit Sub
Handler:
If Err.Number = 1004 Then 'Application-defined or
object-defined error
MsgBox "Your entry was invalid, please try again."
GoTo GetAddress
End If
MsgBox Err.Description
End Sub

If ya need anything give a shout. I should be here another couple of
hours


NickHK

user input of a range of cells
 
Naim,
You can provide the user with an InputBox, with appropriate prompt and
Type:=8

Dim rng As Range
Const RangeOnly As Long = 8
Set rng = Application.InputBox("Select your cells", , , , , , , RangeOnly)

Add error trapping to check for cancel.

NickHK

"naz" wrote in message
oups.com...
How do I initiate a user input of a range of cells after clicking a
visual object? I want the program to pause whilst the user selects a
range of cells on the worksheet whcih will be used later to input a
file directory.

I appreciate any help.

Thanks Naim.





All times are GMT +1. The time now is 05:20 PM.

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