Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

read data excel spreadsheet

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Read data from Excel spreadsheet

Read data from Excel spreadsheet

ResolvedVersion 2003

Kenneth has attended:
Excel VBA Intro Intermediate course

Read data from Excel spreadsheet

How do we read data from an Excel spreadsheet without opening the workbook?

RE: Read data from Excel spreadsheet

Hi Ken, thanks for posting your query. Open a new spreadsheet and write your name into cell A1. Then save that spreadsheet to c:\. Close it, and then open another new spreadsheet, Alt + F11 and create a new module with this code:

Sub ReadClosed()

Dim strPath As String
Dim strFile As String
Dim strInfoCell As String
Dim myvalue As String

strPath = "c:\"
strFile = "myspreadsheet.xls"
strInfoCell = "'" & strPath & "[" & strFile & "]Sheet1'!R1C1"

myvalue = ExecuteExcel4Macro(strInfoCell)
MsgBox myvalue
Sheets("Sheet1").Range("A1").Value = myvalue


End Sub

That should display a messagebox with the value from your closed spreadsheet and write it into cell A1 on your new sheet. I haven't tested this with vast quantities of data, but you should be able to cannibilise this code for what you want to do.

Hope this helps,

Anthony

Sun 25 Jul 2010: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

VBA tip:

Use GoTo to Select A Cell With VBA

To select a certain cell on a Worksheet you can use:

Application.Goto Reference:=Range("V300")

or more simply

Range("V300").Select

If, on the other hand, you want the selected cell to be the top/left cell on the screen you use:

Application.Goto Reference:=Range("V300"), Scroll=True

View all VBA hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.