98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft VBA Training and help » Read data from Excel spreadsheet
Read data from Excel spreadsheet
Resolved · Low Priority · Version 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 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
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
VBA tip:Stop Display Alerts In ExcelWhen creating or deleting a Worksheet in Excel you don't want Excel to inform you "A file already exists....." Or "Do you want to save this file...". |