Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default InputBox that obtains Workbook, Worksheet, and Range

I have a macro that takes a range of cells as input. I am trying to use an
InputBox or something similiar to let the user select the range they need.
First how would I let the user select their range in the format :
'[Book1.xls]Sheet2'!$F$6:$F$10, and second how would I transform that into a
variable that's similiar to Workbooks().WorkSheets().Range()?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default InputBox that obtains Workbook, Worksheet, and Range

Hi J,

Try something like:

'=============
Public Sub Tester()
Dim Rng As Range
Dim sStr As String

On Error Resume Next
Set Rng = Application.InputBox( _
Prompt:="Select range", _
Type:=8)
On Error GoTo 0

If Not Rng Is Nothing Then
sStr = Rng.Address(external:=True)
MsgBox sStr
End If

End Sub
'<<=============


---
Regards,
Norman



"J@Y" wrote in message
...
I have a macro that takes a range of cells as input. I am trying to use an
InputBox or something similiar to let the user select the range they need.
First how would I let the user select their range in the format :
'[Book1.xls]Sheet2'!$F$6:$F$10, and second how would I transform that into
a
variable that's similiar to Workbooks().WorkSheets().Range()?



  #3   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default InputBox that obtains Workbook, Worksheet, and Range

The .address function returns the full path in a string, but how would I use
that string as a range variable that incorporates the Workbook and Worksheet?

Also, the prompt box doesnt allow me to select a different workbook while
its open. Is there a way around it?

Thanks.

"Norman Jones" wrote:

Hi J,

Try something like:

'=============
Public Sub Tester()
Dim Rng As Range
Dim sStr As String

On Error Resume Next
Set Rng = Application.InputBox( _
Prompt:="Select range", _
Type:=8)
On Error GoTo 0

If Not Rng Is Nothing Then
sStr = Rng.Address(external:=True)
MsgBox sStr
End If

End Sub
'<<=============


---
Regards,
Norman



"J@Y" wrote in message
...
I have a macro that takes a range of cells as input. I am trying to use an
InputBox or something similiar to let the user select the range they need.
First how would I let the user select their range in the format :
'[Book1.xls]Sheet2'!$F$6:$F$10, and second how would I transform that into
a
variable that's similiar to Workbooks().WorkSheets().Range()?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default InputBox that obtains Workbook, Worksheet, and Range

Hi Jay,

The .address function returns the full path in a string, but how would I
use
that string as a range variable that incorporates the Workbook and
Worksheet?


You already have the range variable, namely Rng. The sStr
variable was only used to demonstrate the range address.

Also, the prompt box doesnt allow me to select a different workbook while
its open. Is there a way around it?


The inputBox does allow the selection of another workbook; try
clicking on 'Window' in the menu bar.


---
Regards,
Norman




"J@Y" wrote in message
...
The .address function returns the full path in a string, but how would I
use
that string as a range variable that incorporates the Workbook and
Worksheet?

Also, the prompt box doesnt allow me to select a different workbook while
its open. Is there a way around it?

Thanks.

"Norman Jones" wrote:

Hi J,

Try something like:

'=============
Public Sub Tester()
Dim Rng As Range
Dim sStr As String

On Error Resume Next
Set Rng = Application.InputBox( _
Prompt:="Select range", _
Type:=8)
On Error GoTo 0

If Not Rng Is Nothing Then
sStr = Rng.Address(external:=True)
MsgBox sStr
End If

End Sub
'<<=============


---
Regards,
Norman



"J@Y" wrote in message
...
I have a macro that takes a range of cells as input. I am trying to use
an
InputBox or something similiar to let the user select the range they
need.
First how would I let the user select their range in the format :
'[Book1.xls]Sheet2'!$F$6:$F$10, and second how would I transform that
into
a
variable that's similiar to Workbooks().WorkSheets().Range()?






  #5   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default InputBox that obtains Workbook, Worksheet, and Range

Ah I didnt realize the range variable incorporates the full path as is.
Thanks very much Norman.

"Norman Jones" wrote:

Hi Jay,

The .address function returns the full path in a string, but how would I
use
that string as a range variable that incorporates the Workbook and
Worksheet?


You already have the range variable, namely Rng. The sStr
variable was only used to demonstrate the range address.

Also, the prompt box doesnt allow me to select a different workbook while
its open. Is there a way around it?


The inputBox does allow the selection of another workbook; try
clicking on 'Window' in the menu bar.


---
Regards,
Norman




"J@Y" wrote in message
...
The .address function returns the full path in a string, but how would I
use
that string as a range variable that incorporates the Workbook and
Worksheet?

Also, the prompt box doesnt allow me to select a different workbook while
its open. Is there a way around it?

Thanks.

"Norman Jones" wrote:

Hi J,

Try something like:

'=============
Public Sub Tester()
Dim Rng As Range
Dim sStr As String

On Error Resume Next
Set Rng = Application.InputBox( _
Prompt:="Select range", _
Type:=8)
On Error GoTo 0

If Not Rng Is Nothing Then
sStr = Rng.Address(external:=True)
MsgBox sStr
End If

End Sub
'<<=============


---
Regards,
Norman



"J@Y" wrote in message
...
I have a macro that takes a range of cells as input. I am trying to use
an
InputBox or something similiar to let the user select the range they
need.
First how would I let the user select their range in the format :
'[Book1.xls]Sheet2'!$F$6:$F$10, and second how would I transform that
into
a
variable that's similiar to Workbooks().WorkSheets().Range()?






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
Range through Inputbox jasmine Excel Programming 3 March 5th 07 12:13 AM
Creating an Index Sheet that obtains a cell Value using VBA David Coyle[_2_] Excel Programming 1 October 30th 06 05:02 PM
InputBox method with range Emily Edgington Excel Programming 6 September 8th 06 06:20 PM
Application.inputbox for another workbook Utkarsh Excel Programming 2 September 8th 06 05:57 PM
Select range with InputBox. Is it possible? Isabel Excel Programming 3 March 16th 06 07:02 PM


All times are GMT +1. The time now is 12:43 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"