reading contents of a file

C

Christopher Brooks

Hello,

How do I open a file browse window and have my spread
sheet read the contents and write them to a worksheet?

Thanks
 
C

Chip Pearson

Christopher,

Try something like the following:


Dim FName As Variant
Dim WB As Workbook
FName = Application.GetOpenFilename("Excel files ,*.xls")
If FName = False Then
' no file chosen
Exit Sub
End If
Set WB = Workbooks.Open(Filename:=FName)
'
' do something with WB
'

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

Tom Ogilvy

Dim fname as String
fname = Application.GetOpenFileName
if fname <> "False" then
workbooks.open fname
End if

If you are talking about something other than an XLS file, then you would
have to be more specific.
 
Top