VB icon

Display Excel Spreadsheet Cell Data

Email
Submitted on: 1/2/2015 12:38:00 AM
By: Lloyd Christmas (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB.NET
Views: 2515
 
     This code snippet shows how to take an existing Excel 2000 document and display the cell data from different worksheets. This may work with other versions of Excel
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Display Excel Spreadsheet Cell Data
// Description:This code snippet shows how to take an existing Excel 2000 document and display the cell data from different worksheets. This may work with other versions of Excel
// By: Lloyd Christmas (from psc cd)
//
// Assumes:The following COM references are required:
Microsoft Excel 9.0 Object Library
Microsoft Office 9.0 Object Library
//**************************************

'Open an Excel document, get a value from 3 cells, all on different worksheets
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet1 As Excel._Worksheet
Dim xlSheet2 As Excel._Worksheet
Dim xlSheet3 As Excel._Worksheet
Dim mytext1 As String
Dim mytext2 As String
Dim mytext3 As String
xlApp = CreateObject("Excel.Application")
xlBook = xlApp.Workbooks.Open("c:\test.xls")
xlSheet1 = xlBook.Worksheets(1)
xlSheet2 = xlBook.Worksheets(2)
xlSheet3 = xlBook.Worksheets(3)
mytext1 = xlSheet1.Range("A1").Value
mytext2 = xlSheet2.Range("A9").Value
mytext3 = xlSheet3.Range("C1").Value
MessageBox.Show(mytext1 + " " + mytext2 + " " + mytext3)
xlBook.Close()


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.