Entrepreneur, Blogger, Author

Monday, August 17, 2009

On Monday, August 17, 2009 by Nishant Verma in , ,    No comments
Below is a piece of code which can be used to read excel sheet and the values in the row or column.
Option Explicit
Dim myExcel,strExcelPath,objSheet
Dim intRow,strRow2Col1,strRow2Col2

Set myExcel = CreateObject("Excel.Application")
strExcelPath = "C:\Book2.xls"

myExcel.WorkBooks.Open strExcelPath
Set objSheet = myExcel.ActiveWorkbook.Worksheets(1)

'Assuming that the first row will contain the name of the column
intRow = 2
Do While objSheet.Cells(intRow, 1).Value <> ""
    strRow2Col1 = objSheet.Cells(intRow, 1).Value
    strRow2Col2 = objSheet.Cells(intRow, 2).Value
'Increment the control to the next row
    intRow = intRow + 1



Post a Comment

Your comments will be reviewed and then published !

Instagram Feed

Web Analytics