CodeItBetter Programming Another VB Programming Blog

How to Read Excel Data

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'MS Office - How to Read Excel Data
'Declarations:

'Lib Reference: Microsoft Excel 11.0 Object Library
'If u not found 11.0 u can fined lower version

'Dim WithEvents xlBook As Excel.Workbook
'Declare it on Top

'Code:

' Write This in Any command button

'Here U mention ur Excel File name
Set xlBook = GetObject(App.Path & "\SampleData.xls")
 
 
xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
xlBook.Application.WindowState = xlMinimized
 
Dim irow As Integer
Dim jcol As Integer
'There r 3 rows X 3 columns in excel   sheet

For irow = 2 To 4
    For icol = 1 To 3
        MsgBox xlBook.Worksheets(1).Cells(irow, icol).Value
    Next
Next
 
'Create  this is an excel sheet and We have rows and
' colums like this Data is started from 2nd row so we
'mentioned in First for loop starts from 2 to till 4
' 1st col     2nd col        3rd col
'  sno       name            sal          1st row
'   1          Test1         223          2nd row
'   2          Test2         223          3rd row
'   3          Test3         223          4th row

Related posts:

  1. How to get data from Excel Worksheet
  2. How to copy data from an Access database into an Excel workbook using a Recordset
  3. How to Resize the columns of a flexgrid at runtime to fit the values to be displayed
  4. How to take data from a VB database application and place it into an Excel spreadsheet
  5. How to create an Excel file from your application
  6. How to Copy data from an Access database into an Excel spreadsheet using a SQL SELECT statement
  7. How to Copy data from an Access database into an Excel spreadsheet
  8. How to create an excel file without using Microsoft Excel
  9. How to Use ADO to get data from a read-only Access database
  10. El Poder de Excel

Filed under: MS Office Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.