This bellow macro is validation that the MSHFlexgrid1 row ZERO will have the column header name the same as the textbox : rates1.Text
But the issue i have now is that if in the grid i have 5 column and it match the same 5 Split(rates1.Text, vbCrLf), it will say that it is good but it needs to validate if the grid header match all text from the textbox. So if i have 10 multiline in the textbox, then i need to have 10 columns in the MSHFlexgrid with the same names in the same sequence.
How can i fix this?
I tried like this but it does not validate all columns:
If MSHFlexGrid1.TextMatrix(0, lngCol) = strParts(lngIndex) Or strParts(lngIndex) = MSHFlexGrid1.TextMatrix(0, lngCol) Then
Dim lngCol As Long Dim lngIndex As Long Dim strParts() As String Dim bFound As Boolean strParts = Split(rates1.Text, vbCrLf) For lngCol = 0 To MSHFlexGrid1.Cols - 1 bFound = False For lngIndex = 0 To UBound(strParts) If MSHFlexGrid1.TextMatrix(0, lngCol) = strParts(lngIndex) Or strParts(lngIndex) = MSHFlexGrid1.TextMatrix(0, lngCol) Then bFound = True Exit For End If Next If Not bFound Then MsgBox "Rate header doesn't match on " & MSHFlexGrid1.TextMatrix(0, lngCol) & ". Please validate.", vbExclamation, "Header Validation" Exit Sub End If Next MsgBox "Rate header match.", vbMsgBoxRight, "Header Validation"
Dim lngCol As Long Dim lngIndex As Long Dim strParts() As String Dim bFound As Boolean strParts = Split(rates1.Text, vbCrLf) If UBound(strParts) <> MSHFlexGrid1.Cols Then MsgBox "Header doesn't match. Please validate.", vbExclamation, "Header Validation" Exit Sub End If For lngCol = 0 To MSHFlexGrid1.Cols - 1 bFound = False For lngIndex = 0 To UBound(strParts) If MSHFlexGrid1.TextMatrix(0, lngCol) = strParts(lngIndex) Then bFound = True Exit For End If Next If Not bFound Then MsgBox "Header doesn't match on " & MSHFlexGrid1.TextMatrix(0, lngCol) & " column. Please validate.", vbExclamation, "Header Validation" Exit Sub End If Next Command1.Enabled = True MsgBox "Good match"
I did a small update on the code.
I will just do 2 other test.
Update on code
Open in new window