i am doing work with excel .. i have imported excel file in MSflexgrid... Now i have prob is that i have to count the records. or we can say that .. count the cells of that excel file. using diff colunm taking into consideration...
thanx
This is not my code but try it out(or you can modify)
=======
Here is a function that accepts a grid control and a column number. It then
totals all the rows of the column and returns the total in the name of the
function. You can probably use or modify this code to do what you need:
Public Function getGridColumnTotal(myGrid As Control, myColumn As Long) As
Single
'Calculate and return the total of all the cells in a grid's column.
'The grid to use is passed into the function as myGrid.
'The column to use is passed into the funcion as myColumn.
Dim counter As Integer, myTotal As Single, myCell As Single
'turn on an error handler
On Error GoTo getGridColumnTotalError
'set the grid's column to the argument passed into the function
myGrid.Col = myColumn
'loop through all the items in the grid
For counter = 0 To myGrid.Rows - 1
'set the grid's row to the counter
myGrid.Row = counter
'if the text in the current cell is numeric
If IsNumeric(myGrid.Text) Then
'retrieve the current cell (pointed to by the grid's Row and Col
properties
myCell = myGrid.Text
'add the cell's contents to a running total
myTotal = myTotal + myCell
End If
Next counter
'return the grid column's total in the name of the function
getGridColumnTotal = myTotal
'exit to keep from falling into the error handler
Exit Function
getGridColumnTotalError:
'use a message box to indicate an error number and error description
MsgBox Err & Error, vbCritical, "getGridColumnTotal Error"
End Function