Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Counting Rows In Flexgrid

I have a for next loop, i want to count how many of the rows in columnd 0 have text.

This is what i have now,

VB Code:
For i = 0 To grdFields.Rows.Count - 1'....... Next

The only thing is when i do this is counts all the rows in the flexgrid, even the ones with nothing in them.

any help would be greatly appreciated.


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Counting Rows
Hi All,

I need a piece of VB script to count the number of rows that are filled in, in my sheet. I need to know this because of the for loop i'm using. But the ammount of rows that are filled in arn't always the same.

thanks in advance.



Autosize Rows In Flexgrid && Loop Through Flexgrid
How to autosize the rows and column in flexgrid?
Mr Flyguy in your tutorial I have tried it but how to call the function

FG_autosizerow(dbgrid) --> i Have tried this but it wont work

How to make my first column of flexgrid enable true and the other column false enable


1 2
aa ww
aa ww
aa ww
I want the 1st column being enable and the 2nd column false enabled

How to achieve this


Counting Rows And Using That # In A Range
I have been working with integrating some of my regular routines into one large macro and have come across a small problem. I need to delete rows when they are a certain value...which isn't a problem...however, I need to know how many rows I have to say do a regression and I don’t know how to imbed that number.

So say I use the following code which is used to automate making a regression of a set of data...

Application.Run "ATPVBAEN.XLA!Regress", CalculationsDataSht.Range("$I$17:$I$8776"), _
CalculationsDataSht.Range("$B$17:$D$8776"), False, False, False, CalculationsDataSht.Range("$M$40"), False, False, _
False, False, , False
Now where it says 8776 which is denoting the final cell to include in the range I need that to represent the number of rows I have AFTER deleting the bad data. So is there any way I can say…count the number of rows between those two and then place that number where 8776 is so I have a kind of floating range of data?

Any help will be much appreciated.

Counting Rows Dynamically

I want to count the number of rows I have in my form. But I want it to start at A16 and go down until there's nothing else written. I have used previously what is quoted but it counts the rows from A1 to A15 which is not part of the wanted rows. Any solutions in mind?




Let lstRw = Sheets("Formulaire").Range("a65536").End(xlUp).Row

MSFlexgrid - Counting Rows
can anybody tell me how to code a counter to show how many records (rows) there are in my msflexgrid ?

Counting Rows In A Table
I'm writing a program which pulls data from a website to fill a source data database i'm using for other tests. Is there any way to find out how many rows are in a table on a webpage. I was using a for loop, but if it hits a row which doesn't exist, it errors. Right now i'm using:

starthunter2 = ie.document.all.tags("table").Item(9).Rowcount

Byt it's saying rowcount isn't a valid property. Anyone know what the correct property would be?

Nevermind, i got it. Turns out it was

starthunter2 = ie.document.all.tags("table").Item(9).Rows.length

Counting Rows In Textbox
What is the easiest way to count the number of rows of text in a textbox?

I think each row has had Return key pressed at the end.

Counting Rows In A Datagrid
im revisiting an issue i havent been able to resolve. How would i go about counting the total number of rows that are pulled within the datagrid. the datagrid1.row for some reason only counts the rows that are visible on the screen. however i would like to have a total count of all rows. how could i go about this. thanks


Counting Rows Of MSHFlexGrid
Guys, how do we count total rows of MSHFlexGrid.


Counting Rows In A Datagrid
Anyone know how to do that?

Counting Rows In Excel
Im trying to count the number of sequencial rows that contain content

Basically Cells A1 ... A30 have content in them already. And I want to beable to count the total number of rows with content without having to use a selection range

The number of rows will change so it needs to be dynamic.

Any ideas or suggestions would be great, Im new to VB in office applications, unfortunately the company I work for refuses to let me do much else.

Counting Valid Excel Rows
How do I count only the rows of an Excel spreadsheet that have data in them? If I use objXL.rows.count I get all of the rows on the sheet. Are there any alternatives function/methods/properties provided by VB? Or do I have to phyiscally count each row in another sub routine?



MsFlexiGrid - Counting Number Of Rows ?
Does anyone know how to count the number of records that are displayed in a msflexigrid control? Cant seem to see the property anywhere?


Counting Number Of Rows In A Datagrid
need help!!

Can anyone help, I need to be able to count the number of rows in a datagrid. The number of rows will vary on a number of occasions


Counting Rows With Data In Excel/VB
I need to loop through all the rows in an Excel file that has data in each row. If I use Workbooks.Application.Rows.Count it returns every row (65235) or whatever. I usually just have around 100 or so rows with data in them. I'm using a For loop to do this. My code goes something like this...

For i = 1 to Workbooks.Application.Rows.Count 'Rows with data that doesn't work

Thanks again in advance.

Type Mismatch On Counting Rows

I have 2 variables which count the number of rows in both worksheets. The row method is expecting 2 numbers. I provide the originalRows and the linkedRows variables in that method
However, I get a 'Type Mismatch' error.
    originalRows = ActiveSheet.UsedRange.Rows.count
    linkedRows = ActiveSheet.UsedRange.Rows.count
       Selection.AutoFill Destination:=Rows("linkedRows : originalRows"), Type:=xlFillDefault

When I put in hard coded numbers, it all seems to work fine:
    Selection.AutoFill Destination:=Rows("210:211"), Type:=xlFillDefault
Can you see what is going wrong, because I am a bit stuck?

Thanks for your time
email me

Counting The Number Of Times A Certain Word Occurs In A Flexgrid Column?
if i had ONE column in a flexgrid, and that column had a few different words occurring randomnly, eg:


like that.... is there a way to count the number of times that the word 'fish' occurs and the number of times 'chicken' occurs? and then send these numbers to two separate labels?


Help - Autoresize FlexGrid Rows
I am trying to create a FlexGrid control in MS Access 97. All is well with the data populating, but because my text is long, I need to use the WordWrap function. Since FlexGrid doesn't autoresize the rows, I need to do it programmatically.

every code i found on the net i think works with VB but not Access. can anyone help?

Transfer Rows From A Flexgrid To Another.
Hello. I have 2 flexgrids, F1 and F2. F1 is populated and F2 is blank. With this code i add rows from F1 to F2:

Private Sub F1_Click()

With F1
.Col = 0
c1 = .Text
.Col = 1
c2 = .Text
.Col = 2
c3 = .Text
.Col = 3
c4 = .Text
.Col = 4
c5 = .Text
End With

If F2.Rows = 0 Then
F2.Rows = 1
F2.Rows = F2.Rows + 1
End If

F2.TextMatrix(F2.Rows - 1, 0) = c1
F2.TextMatrix(F2.Rows - 1, 1) = c2
F2.TextMatrix(F2.Rows - 1, 2) = c3
F2.TextMatrix(F2.Rows - 1, 3) = c4
F2.TextMatrix(F2.Rows - 1, 4) = c5

End Sub
I want that clicking on F1 to check if selected row exist in F2. If it doesnt exist, add it. Else delete from F2. Is this possible? And if yes, how? Thnx.

Filtering Rows In Flexgrid
Hello, I have an ado data control linked to an mshflexgrid. How can i get the flexgrid to only display rows whose fields have a certain value? That is, I want to filter out rows that do not match certain criteria. Thanks.

Flexgrid Shows No Rows
I've been away from VB stuff for a number of months.
Today I opened up my projects and none of the mshflexgrids shows any rows.
I've got them bound to ado controls. I've tried doing an adoctrl.recordset.recordcount to make sure that there should be rows to show, and I get the correct amount of rows, but the rows never show in flexgrid.
The same is true with all the flexgrids in all my projects.

Flexgrid Adding Rows
I have a flexgrid and I get the data for the grid from a database
hence I have the first row as fixed row.

But I also want the user to add a row above my first show that is displayed
That is effectively add one row above the second row (the first row being my greyed out fixed row).
Since I have that fixed row my foll code does not work

If Me.MSFlexGrid1.Row = 1 Then
Me.MSFlexGrid1.AddItem "", Me.MSFlexGrid1.Row - 1

any one has any way I can add one row above my first row of data by still having that fixed row.


Flexgrid Adding Rows
I am using a MSFlexgrid and I need to add a new row in the middle of
the grid

Assuming that I already have 5 rows with data in it How would I add a new row after the 2'nd row ? After I do that I need to make sure that the values of the rows below it are pushed down. Is this automatically taken care if not How can I do this ?


Copying Rows From A Flexgrid

I have populated a MSHflexgrid and I am able to select the columns and rows in it by clicking, but can't copy the contents by pressing Ctrl+C and paste in any other application.

Is it possible to copy a single row or column using the usual ctrl+c method on flexgrids?



How To Get Number Of Rows In Flexgrid
i select 5 rows in a flexgrid and i want to get the number of rows i selected. if i select 5 i will get 5 rows at the msgbox etc...

I want to do that to delete these 5 lines i have selected from the this possible somehow? please help i use visual basic 6

Flexgrid Highlight Rows
For some reason my flexgrid will not highlight the rows if they are clicked. I have it set to hightlight always in the properties and I also have

DPlanflex.HighLight = flexHighlightAlways

in my form_load. I also have tried this in my code but it leaves the previous row highlighted.

With DPlanflex
.RowSel = .Row
For i = 0 To 8
.Col = i
.CellBackColor = &H8000000F
Next i
End With

Any ideas?

Add New Item To End Of Flexgrid Rows

I've polupated a txtfile to MsFlexgrid control; i need to add new items, but each time i add a new item, it adds the new item to the first row and remove the old item in first row.
that was my code:

Private Sub cmd_add_Click()
Dim LayerF As String
Dim LayerT As String
Dim ColorF As String
Dim ColorT As String
Dim LineTypeF As String
Dim LineTypeT As String
Dim LayerBlock As String

LayerF = txt_lf.Text
LayerT = txt_lt.Text
ColorF = cb_cf.Text
ColorT = cb_ct.Text
LineTypeF = cb_lf.Text
LineTypeT = cb_lt.Text
LayerBlock = txt_lbloco.Text

If LayerF = "" Or LayerT = "" Then
MsgBox "Layer de Entrada ou de Saída não definido.", _
vbCritical + vbOKOnly
ElseIf ColorF = "" Or ColorT = "" Then
MsgBox "Valor de côr de Entrada ou de Saída não definida.", _
vbCritical + vbOKOnly
ElseIf LineTypeF = "" Or LineTypeT = "" Then
MsgBox "Tipo de linha de Entrada ou de Saída não definido.", _
vbCritical, vbOKOnly
If x = 0 Then
x = 1
End If

fgp.Rows = fgp.Rows + 1

fgp.TextMatrix(x, 1) = LayerF
fgp.TextMatrix(x, 2) = ColorF
fgp.TextMatrix(x, 3) = LineTypeF
fgp.TextMatrix(x, 4) = "=>"
fgp.TextMatrix(x, 5) = LayerT
fgp.TextMatrix(x, 6) = ColorT
fgp.TextMatrix(x, 7) = LineTypeT
fgp.TextMatrix(x, 8) = LayerBlock

x = x + 1

txt_lf.Text = ""
txt_lt.Text = ""
cb_cf.Text = ""
cb_ct.Text = ""
cb_lf.Text = ""
cb_lt.Text = ""
txt_lbloco.Text = ""
End If
End Sub

I need to add the item to the end of the flexgrid rows.

António Miranda

How To Count The Rows In A Flexgrid
Hey guys,

I have a flex grid that displays records from a backend mysql table. Is there a property that gives me a total number of records currently being displayed in the flexgrid control?

Please help


Removing The Rows In MS Flexgrid
i have written a program which add rows in the Msflex grid dynamically.
Like i have a text box, and rows will be entered based on the value in the text box

Pls tell me how to remove the rows in the MS Flex grid

Copying Rows From A Flexgrid

I have populated a MSHflexgrid and I am able to select the columns and rows in it by clicking, but can't copy the contents by pressing Ctrl+C and paste in any other application.

Is it possible to copy a single row or column using the usual ctrl+c method on flexgrids?



Not Adding Rows In Flexgrid
I have a form where the user keeps track of income and expenditure. When I click on the add button, if there are already 4 rows (incl fixed) then it does not add another row, but pushes every thing up one row only showing three rows of data. Any suggestions please.
VB Code:
Private Sub cmdAdd_Click()    '...Add new entry to grid    '...put text from textboxes into variables Dim msg As String InputDate = DateDesc = txtDesc.TextIf optAmount(0) Then    Income = Format(Val(txtAmount.Text), "#,##0.00;;""")Else    Expenditure = Format(Val(txtAmount.Text), "#,##0.00""")End If   If grdFinance.Text = "" Then      msg = grdFinance.Rows + 1 & Chr$(9) & InputDate & Chr$(9) & Desc & Chr$(9) & Income & Chr$(9) & Expenditure              'add variable 'msg' to the grid        grdFinance.AddItem msg            'remove empty row (if it exists)        grdFinance.RemoveItem 1Else    msg = grdFinance.Rows + 1 & Chr$(9) & InputDate & Chr$(9) & Desc & Chr$(9) & Income & Chr$(9) & Expenditure         grdFinance.AddItem msgEnd If '...reset value to nothingIncome = "0"Expenditure = "0" txtDesc.Text = ""txtAmount.Text = ""txtDesc.SetFocus End Sub


Print Rows In Flexgrid
With the code

Dim MyCells as String
MyCells = grdMembersDetails.Clip

I want to make it print over 2 lines on the page. How would I enter the string to but in the "& VbCrLf &" in place of the "& Chr$9 &" (I think this is the tab)

Also, how do I make a space between the text from each cell. At the moment it is just one long line.


Can I Add Rows To The Flexgrid Control?
Can I add rows to the flexgrid control MSFlexGrid1 in VB6?

Flexgrid Visible Rows
I'm back. I couldn't do this job without you guys.

I have a flexgrid with 100 rows. Only 10 are visible at anytime. How do I make a particular row visible, i.e. how do I make the flexgrid scroll to a particular row. I've tried everything and nothing works.

There is a RowIsVisible command that only tells me if the row is visible or not.

Any suggestions?

Fixed Rows In Flexgrid
Hello everybody,

I just found out that you can use multiple fixed rows for your grid. Right now I would like to use 2 fixed rows.. 1 on top of the grid and another on the last row.

But when I set my fixedrows to 2, then my first 2 rows are always fixed.

Is it possible to do this ?



Select Rows In Flexgrid
I have a MSFlexgrid. I would like to know which rows are selected.
If I use flexgrid.rowsel property will give me only as if only one row were selected.

Flexgrid (what Rows Are Displayed)

I am using VB6 and a flexgrid grid.

The grid varies on length but can be over 100 rows long.
The size of the grid means only 10 rows are shown at once and you must scroll to view the rest.

IS there any way to find out what rows are shown on the screen
ie top and bottom visible row. I cannot seem to find details of this.

is there any limit on the compiled exe size for a normal program as one of mine is a 1200k .exe file with about 35 forms.

Thanks for any help given.


Export FlexGrid Rows To TextBox

I want to export flexgrid to text by Row so textbox will be like that

---------> To the end of Rows

I'm using this code it give me only the first Row

Private Sub Command1_Click()

Dim IRow As Integer

IRow = FG1.Row

If FG1.TextMatrix(IRow, 15) = "JAMAL" And FG1.TextMatrix(IRow, 16) = "YES" Then

Text1.text = "GGG" & "/" & vbCrlf & FG1.TextMatrix(IRow, 1) & FG1.TextMatrix(IRow, 2) & _
FG1.TextMatrix(IRow, 3) & vbCrlf & FG1.TextMatrix(IRow, 4) & "//"

ElseIf If FG1.TextMatrix(IRow, 15) = "MIKE" And FG1.TextMatrix(IRow, 16) = "NO" Then

Text1.text = "JJJ" & "/" & vbCrlf & FG1.TextMatrix(IRow, 1) & FG1.TextMatrix(IRow, 2) & _
FG1.TextMatrix(IRow, 3) & vbCrlf & FG1.TextMatrix(IRow, 4) & "//"

End If

End Sub

Problem With Deletng Rows In FlexGrid
I have a very strange problem. I'm trying to delete all the rows in a flexgrid, but for some reason I can't delete the last row. I used AddItem to add rows during the couse of the program (if that means anything!)
'Two of the many ways I've tried
For iX = 0 To Grid1.Rows
'Remove row from FlexGrid
Grid1.RemoveItem (0)
Next iX
'or this
Do Until Grid1.Rows = 0
'Remove row from FlexGrid
Grid1.RemoveItem (0)

Determining Selected Rows In Flexgrid
Hi guys i am trying to create excell like functionality for my MS flexgrid. Basically when a few rows of the grid are selected i want to make a calculation of the sum of teh selected rows. Each row has a column with some numbers, so what i want to do is be able to determine which rows are selected and count up the values of teh columns in selected rows. The problem is that i do not know how to determine if a row ios selected or not. grid1.rowsel only gives me teh last row i selected but non of teh other selected rows. Thanx for the help

FlexGrid Help - Update Multiple Rows
The script below puts some text in column 4 of my flexgrid when one date is less than the other, it also changes the colour of the cell. This script works fine but I have 100+ rows. I could write this script for each row of my flexgrid but that will take me hrs/days. Can someone please help me write a script to automate this for all rows.

Cheers, Scotty

Private Sub Form_Load()
Dim dDate1 As Date
Dim d2Date1 As Date

dDate1 = CDate(Format(MSFlexGrid.TextMatrix(1, 3), "dd/mm/yyyy"))
d2Date1 = CDate(Format(PDate.Text1.Text, "dd/mm/yyyy"))
If dDate1 < d2Date1 Then
MSFlexGrid.TextMatrix(1, 4) = "Investigate Problem"
Call ColorRow(1, vbWhite, vbRed)
MSFlexGrid.TextMatrix(1, 4) = "OK"
End If

Deleting Highlighted Flexgrid Rows

Anyone know how I can delete all Flexgrid rows that a user has highlighted? There is no problem in picking up the vbKeyDelete event and I've managed to code a delete function which deletes rows that match a certain criteria but its knowing which rows are highlighted that is giving me a headache.

Any help appreciated,

Increasing Flexgrid Rows More Than Max Limit
U know that the max. no of rows for msflexgrid is 14000 rows, how can i increase it to more than 100,000 rows ?
because i have a set of database +/- 100,000 records

Flexgrid: Make Certain Rows Clickable
What I want to do is make certain rows available for more information. For instance, If Mid(.Textmatrix(i, j), 1, 1) = "T" I want the user to be able to see more information. It's not exactly just a row click event. I only want those rows that meet the criteria to be able to be viewed when clicked on and I want the user to know the information is there. Like maybe, if the criteria is met, put a button into a column of those rows only? I could colour those rows meeting the criteria, but I think it might make the current interface look unpolished. Any ideas anyone?

Export FlexGrid Rows To TextBox

I want to export flexgrid to text by Row so textbox will be like that

vbCrlf ' To the end

I'm using this code it give me only the first Row

VB Code:
Private Sub Command1_Click() Dim IRow As Integer IRow = FG1.Row If FG1.TextMatrix(IRow, 15) = "JAMAL" And FG1.TextMatrix(IRow, 16) = "YES" Then Text1.text = "GGG" & "/" & vbCrlf & FG1.TextMatrix(IRow, 1) & FG1.TextMatrix(IRow, 2) & _FG1.TextMatrix(IRow, 3) & vbCrlf & FG1.TextMatrix(IRow, 4) & "//" ElseIf If FG1.TextMatrix(IRow, 15) = "MIKE" And FG1.TextMatrix(IRow, 16) = "NO" Then Text1.text = "JJJ" & "/" & vbCrlf & FG1.TextMatrix(IRow, 1) & FG1.TextMatrix(IRow, 2) & _FG1.TextMatrix(IRow, 3) & vbCrlf & FG1.TextMatrix(IRow, 4) & "//" End If End Sub

If i fill only three Rows then the textbox should be like that


Not all the Row's

Date And Days Rows In Flexgrid?
I made a flexgrid with first row displaying the dates of the month selected from the combo which contains months.Is it possible to put in the next row the week days associated with the date?
Can monthview control be of any help in this?

Changing Height Of Rows In Flexgrid

How can I to change the height , some or all rows of the FlexGrid ?


How Would I Remove Empty Rows From FlexGrid?
Rough day today...

Ok...More MSFlexGrid issues. I need a function which removes all the empty rows from my MSFlexGrid but keep the populated rows.

Urgent... Removing Rows In Flexgrid
OK here's the situation, I got an assignment for university and I seem to have a problem with removing rows from MSFlexgrid.

This is what I am doing (a quick summary - if you want code I'll post it in the next post)...

My form loads, and fills the grid with values from my database (ie a current order list).

I have got 4 options at the bottom and when the user clicks it it clears the rows then reinserts the data into the fields (this is done through the sql statement).

This is where the problem arises... every time I delete rows, it gets to the point where it says cannot remove last fixed row

I really do need help with this cause I need to submit this on friday or monday latest!

Also I would like to remove the first row that is always empty.

Copyright © 2005-08, All rights reserved