Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata
Sub Test()

If IsHeader = True Then
 MsgBox "Has Header"
Else
 MsgBox "No Header"
End If

End Sub
Public Function IsHeader() As Boolean

 A1Pattern = RegExPattern(Range("A1").Value)
 A2Pattern = RegExPattern(Range("A2").Value)

If A1Pattern = A2Pattern Then
 IsHeader = True
End If

End Function


Public Function RegExPattern(my_string) As String
RegExPattern = ""
'''Special Character Section'''
Dim special_charArr() As String
Dim special_char As String

special_char = "!,@,#,$,%,^,&,*,+,/,\,;,:"
special_charArr() = Split(special_char, ",")
'''Special Character Section'''

'''Alpha Section'''
Dim regexp As Object
Set regexp = CreateObject("vbscript.regexp")

Dim strPattern As String
strPattern = "([a-z])"

With regexp
    .ignoreCase = True
    .Pattern = strPattern
End With
'''Alpha Section'''

Dim buff() As String
'my_string = "test1*1#"
ReDim buff(Len(my_string) - 1)
Dim i As Variant
For i = 1 To Len(my_string)
    buff(i - 1) = Mid$(my_string, i, 1)
    char = buff(i - 1)
    If IsNumeric(char) = True Then
        'MsgBox char & " = Number"
        RegExPattern = RegExPattern & "([0-9])"
    End If
    For Each Key In special_charArr
     special = InStr(char, Key)
      If special = 1 Then
        If Key <> "*" Then
            'MsgBox char & " = Special NOT *"
            RegExPattern = RegExPattern & "^[!@#$%^&()].*$"
        Else
            'MsgBox char & " = *"
            RegExPattern = RegExPattern & "."
        End If
      End If
    Next
    If regexp.Test(char) Then
        'MsgBox char & " = Alpha"
        RegExPattern = RegExPattern & "([a-z])"
    End If
Next
'RegExPattern = Chr(34) & RegExPattern & Chr(34)
'MsgBox RegExPattern
End Function

  • No labels