Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cells count in MS EXCEL 1

Status
Not open for further replies.

vinidel

IS-IT--Management
Jan 23, 2004
78
US
Hi ALL,

How can I find out how many cells actually have data in an excel sheet using VB.NET Code?

Thanks
 
Here giving a rough idea about it...
Code:
Imports Excel

Public Class Form6
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim xlapp As New Application
        Dim xlwb As Workbook
        xlwb = xlapp.Workbooks.Open("c:\temp\ringtones.xls")
        xlwb.Application.Visible = True
        Dim xls As Excel.Sheets
        Dim xlsheet As New Excel.Worksheet
        Dim intRows As Integer
        xls = xlwb.Worksheets
        xlsheet = CType(xls.Item(1), Excel.Worksheet)
        xlsheet.Activate()
        intRows = xlsheet.UsedRange.Rows.Count
        MessageBox.Show(intRows)
    End Sub
End Class

Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top