0
こんにちは、私は自分のセルの一部をcurrentdateで更新しようとしていますので、次のようにしましたが、セルを更新できませんでした。各ループ更新セルについて
EDIT:コード全体から欠落している機能を追加します。
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(Cell)?配列に割り当てようとしています –
残念ですが、他の関数を貼り付けるのを忘れました – user3167398