reading contents of a file

  • Thread starter Thread starter Christopher Brooks
  • Start date Start date
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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top