Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using Dialog to select a Workbook, Worksheet and Range

I am writing an Excel Macro that will automate the process of consolidating
ranges from a number of workbooks into one workbook.

On a worksheet the user enters the workbook name, sheet name, and range for
each source workbook
C:\Abc.xls Sheet1 a1:z100
C:\Invoices\Invoices.xls May2005 g15:m25
C:\Sales\Sales.xls Current B23:AA45


In the source workbook column the user can type the name of the workbook or
click on the Find button. The find button uses the vba function
GetOpenFilename() to open a dialog box and allow the user to select an Excel
spreadsheet without opening it and puts the selected file name in the
appropriate column.

Any ideas how I can expand this function to allow the user to open the file,
select a worksheet and a range of cells then close the workbook returning
the workbook name, worksheet name and the range address back to my original
workbook.

I hope the above makes sense.

TIA
Tony


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Using Dialog to select a Workbook, Worksheet and Range

Hi Tony,

Try this

Dim fileToOpen
Dim rng As Range

fileToOpen = Application _
.GetOpenFilename("Microsoft Excel Files (*.xls), *.xls")
If fileToOpen < False Then
Workbooks.Open fileToOpen
Set rng = Application.InputBox("Select a range from any worksheet",
Type:=8)
If Not rng Is Nothing Then
MsgBox "Workbook: " & ActiveWorkbook.FullName & vbNewLine & _
"Worksheet: " & rng.Parent.Name & vbNewLine & _
"Range: " & rng.Address
End If
ActiveWorkbook.Close savechanges:=False
End If



--
HTH

Bob Phillips

"Tony Starr" wrote in message
...
I am writing an Excel Macro that will automate the process of

consolidating
ranges from a number of workbooks into one workbook.

On a worksheet the user enters the workbook name, sheet name, and range

for
each source workbook
C:\Abc.xls Sheet1 a1:z100
C:\Invoices\Invoices.xls May2005 g15:m25
C:\Sales\Sales.xls Current B23:AA45


In the source workbook column the user can type the name of the workbook

or
click on the Find button. The find button uses the vba function
GetOpenFilename() to open a dialog box and allow the user to select an

Excel
spreadsheet without opening it and puts the selected file name in the
appropriate column.

Any ideas how I can expand this function to allow the user to open the

file,
select a worksheet and a range of cells then close the workbook returning
the workbook name, worksheet name and the range address back to my

original
workbook.

I hope the above makes sense.

TIA
Tony




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using Dialog to select a Workbook, Worksheet and Range

Thanks Bob

I will give it a try.



"Bob Phillips" wrote in message
...
Hi Tony,

Try this

Dim fileToOpen
Dim rng As Range

fileToOpen = Application _
.GetOpenFilename("Microsoft Excel Files (*.xls), *.xls")
If fileToOpen < False Then
Workbooks.Open fileToOpen
Set rng = Application.InputBox("Select a range from any worksheet",
Type:=8)
If Not rng Is Nothing Then
MsgBox "Workbook: " & ActiveWorkbook.FullName & vbNewLine & _
"Worksheet: " & rng.Parent.Name & vbNewLine & _
"Range: " & rng.Address
End If
ActiveWorkbook.Close savechanges:=False
End If



--
HTH

Bob Phillips

"Tony Starr" wrote in message
...
I am writing an Excel Macro that will automate the process of

consolidating
ranges from a number of workbooks into one workbook.

On a worksheet the user enters the workbook name, sheet name, and range

for
each source workbook
C:\Abc.xls Sheet1 a1:z100
C:\Invoices\Invoices.xls May2005 g15:m25
C:\Sales\Sales.xls Current B23:AA45


In the source workbook column the user can type the name of the workbook

or
click on the Find button. The find button uses the vba function
GetOpenFilename() to open a dialog box and allow the user to select an

Excel
spreadsheet without opening it and puts the selected file name in the
appropriate column.

Any ideas how I can expand this function to allow the user to open the

file,
select a worksheet and a range of cells then close the workbook
returning
the workbook name, worksheet name and the range address back to my

original
workbook.

I hope the above makes sense.

TIA
Tony






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
de-select range in other workbook? Ron Excel Programming 3 September 22nd 04 12:50 PM
Select a range and copy to new workbook juan Excel Programming 0 July 23rd 04 11:53 PM
Select and move range throughout workbook ExcelBeginner[_3_] Excel Programming 2 April 20th 04 01:37 PM
open file dialog-select file-import worksheet Divinedar Excel Programming 1 January 16th 04 07:13 PM
RefEdit - cannot select range on another workbook Rob Excel Programming 1 November 26th 03 07:48 PM


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"