Wilder1626
asked on
VB6 - Count number of selected cells in MSHFlexgrid1
Hi
I would like to know how i can count the number of cells i have selected in my MSHFlexgrid_1.
Normally, it would be a count of all the cells highlighted.
How can i do that?
Thanks again
I would like to know how i can count the number of cells i have selected in my MSHFlexgrid_1.
Normally, it would be a count of all the cells highlighted.
How can i do that?
Thanks again
Selected in one row?
Hi Wilder,
can you post a snap shot of selection and the expected answer (count of cells)?
can you post a snap shot of selection and the expected answer (count of cells)?
Try this.
Dim MaxRow As Long
Dim MaxCol As Long
Dim FirstRow As Long
Dim FirstCol As Long
Dim intCount As Integer
With MSFlexGrid1
FirstCol = .Col
FirstRow = .Row
MaxRow = .RowSel
MaxCol = .ColSel
Dim i, j As Integer
For i = FirstRow To MaxRow
For j = FirstCol To MaxCol
intCount = intCount + 1
Next
Next
MsgBox intCount
End With
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Sha
MartinLiss
when i'm using code from ID: 40358522, it works but only if i select from left to right or top to bottom.
But if i select from right to left or bottom to top, it does not count.
Would you know why?
MartinLiss
when i'm using code from ID: 40358522, it works but only if i select from left to right or top to bottom.
But if i select from right to left or bottom to top, it does not count.
Would you know why?
Private Sub MSHFlexGrid_1_GotFocus()
'selected_cell
Dim MaxRow As Long
Dim MaxCol As Long
Dim FirstRow As Long
Dim FirstCol As Long
Dim intCount As Integer
With MSHFlexGrid_1
FirstCol = .Col
FirstRow = .Row
MaxRow = .RowSel
MaxCol = .ColSel
Dim i, j As Integer
For i = FirstRow To MaxRow
For j = FirstCol To MaxCol
intCount = intCount + 1
Next
Next
selected_cell = intCount
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again for your help. This is working great.
Sorry for the delay.
Sorry for the delay.
No problem. glad I could help.