change case "LAST2DAY" to LASTDAY
im in stuck
Function GetDate()
Dim dateStr As Variant
Dim dateArr As Variant
Dim dateResult As Variant
Dim term As String
Dim termFormat As String
Dim regEx As New RegExp
Dim regEx2 As New RegExp
Dim dateFormat As String
Dim strPattern As String: strPattern = "{(.*?)}"
Dim nextCell As String
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
With regEx2
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
'Set Myrange = ActiveSheet.Range("C1:C255")
'Set Myrange = ActiveSheet.Columns(1)
Dim regexDateStr As String
Dim a As String
'regexDateStr = Myrange.value
'Column 1 is B
For Each c In ActiveSheet.Range("B1:B255")
c.Activate
regexDateStr = c.value
If regEx.Test(regexDateStr) Then
'MsgBox (regexDateStr)
a = GetParen2(regexDateStr)
dateArr = Split(a, ".")
term = dateArr(0)
If ArrayLen(dateArr) > 0 Then
dateStr = Date
termFormat = dateArr(0)
If ArrayLen(dateArr) > 1 Then
termFormat = dateArr(1)
Select Case (term)
Case "TODAY"
dateStr = Date
Case "LASTDAY"
dateStr = DateAdd("d", -1, Date)
Case "LAST2DAY"
dateStr = DateAdd("d", -2, Date)
End Select
End If
End If
If dateStr <> Empty Then
' dateResult = Format(dateStr, termFormat)
dateFormat = Format(dateStr, termFormat)
End If
'regEx2.Replace(
c.Offset(, 1).value = regEx2.Replace(regexDateStr, dateFormat)
End If
Next c
'MsgBox (dateResult)
'MsgBox (Format(cur, "dd/MM/yyyy"))
End Function