ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to load a file (https://www.excelbanter.com/excel-programming/442997-how-load-file.html)

Joy

how to load a file
 
I am new to Excel vba programming. I am stuck with a problem:
We want to put a button on an Excel sheet. when user clicks it, there will
be browse message box popping up, and user can select a file stored in local
disk. When it is successfully loaded, the macro could read data from the file.

Can anyone give some sketch of how to do it?

many many thanks!!

Gord Dibben

how to load a file
 
You could start with this which displays your default folder.

Sub open_file()
filetoopen = Application _
.GetOpenFilename("Excel Files (*.xls), *.xls")
If filetoopen < False Then
Workbooks.Open Filename:=filetoopen
End If
End Sub

Browse to your workbook and Open it.

Note: the opened workbook will now be Activeworkbook.


Gord Dibben MS Excel MVP

On Tue, 1 Jun 2010 09:04:01 -0700, Joy
wrote:

I am new to Excel vba programming. I am stuck with a problem:
We want to put a button on an Excel sheet. when user clicks it, there will
be browse message box popping up, and user can select a file stored in local
disk. When it is successfully loaded, the macro could read data from the file.

Can anyone give some sketch of how to do it?

many many thanks!!




All times are GMT +1. The time now is 09:59 AM.

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