0
你好傢伙我試圖用currentdate更新我的一些單元格,所以我做了以下操作,但無法更新單元格。對於每個循環更新單元格
編輯:從整個代碼中添加缺少的功能。
Sub GetField32AFromCell()
For Each Cell In Worksheets("MM_Creation_Success").Range("G2:G9")
'Get cell which is right side of the current cell in for each loop
Dim nextRange As Variant: nextRange = Cell.Offset(0, 1).Value
'split the value of the cell into string array
Dim splitString() As String: splitString = SplitStringByNewLine(Cell)
For Each sString In splitString
Dim newLine As String: newLine = sString
newLine = TryGetField32A(newLine)
If Not newLine = "" Then
Dim newDateString As String: newDateString = GetCurrentDate("yymmdd")
Dim new32AField As String: new32AField = Mid(newLine, 7)
new32AField = newDateString + new32AField
'Set nextRange = new32AField
'MsgBox (nextRange)
End If
Next
Next
End Sub
Public Function SplitStringByNewLine(stringArray As Variant) As String()
SplitStringByNewLine = Split(stringArray, Chr(10))
End Function
Public Function TryGetField32A(newLine As String) As String
If newLine Like ("*:32A:*") Then
TryGetField32A = Mid(newLine, Len("*32A::"), Len(newLine))
'MsgBox ("Found Tag 32A: " + field32AVal)
End If
End Function
Public Function GetCurrentDate(dateFormat As String) As String
Dim todayDate As String: todayDate = Format(Date, dateFormat, vbMonday, vbUseSystem)
GetCurrentDate = todayDate
'MsgBox ("Current Date in Format (" + dateFormat + "): " + todayDate)
End Function
是不是你到這兒'splitString = SplitStringByNewLine(小區)'錯誤?試圖分配到一個數組 –
對不起,我忘了粘貼其他功能 – user3167398