OpenOffice Basic - Finding Number of Data Points in Column -


i need find number of data points within single column , place value in given cell on openoffice calc spreadsheet. here code far i'd appreciate if can tell me i'm going wrong or missing. thanks.

const data_col = 1 'column number data const data_row_start = 2 'start row data

'this function finds number of data points in data column data_col 'the aim of function determine number of data points in column 'you need make use of constants data_row_start (= 2) , data_col (= 1) 'in function. specifically, function uses information first data point in row data_row_start (= 2) , in data in column data_col (= 1).

function findnumberofdatapoints() long

dim data_col double dim data_row_start double dim count double dim row integer  count = 0 row = data_row_start   while activesheet.cells(data_row_start,data_col)<>""          row = row + 1         count = count + 1  wend  if activesheet.cells(data_row_start,data_col)> 0     row = row + 1  end if   count = activesheet.cells(row,data_col)  activesheet.range("c11") = count 'place count value in cell c11 

end function

you can find used area, example, finds last used row

function getlastusedrow(osheet) integer   dim ocell   dim ocursor   dim oaddress   ocell = osheet.getcellbyposition( 0, 0 )   ocursor = osheet.createcursorbyrange(ocell)   ocursor.gotoendofusedarea(true)   oaddress = ocursor.rangeaddress   getlastusedrow = oaddress.endrow end function 

you need @ column rather row.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -