Loop through every Cell in the FlexGrid and compare its value to the TextBox value.
Code:Dim row As Long Dim col As Long Dim exists as boolean With Me.MSFlexGrid1 For row = .FixedRows To .Rows - 1 For col = .FixedCols To .Cols - 1 'use vbBinaryCompare for a Case Sensitive search If StrComp(Text1.Text, Me.MSFlexGrid1.TextMatrix(row, col), vbTextCompare) = 0 Then MsgBox "Data already exists in grid" exists = True Exit For End If Next If exists Then Exit For 'already found the data no need to continue the loop Next If Not exists then MsgBox "Need to add data to the grid. The question is where?" End If End With




Reply With Quote