2016-12-02 1 views
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 
+0

는 여기에'splitString = SplitStringByNewLine (셀)'오류를 얻고 있지? 배열에 할당하려고 시도했습니다 –

+0

다른 기능을 붙여 넣는 것을 잊어 버려 죄송합니다. – user3167398

답변

0

당신이 nextRange로 표시되는 셀에 new32AField을 넣어 의미한다면, 먼저 nextRange 실제로 셀을 나타내는 확인해야하지 그 값이 포함되어

Dim nextRange As Range: Set nextRange = Cell.Offset(0, 1) 

을 그리고 당신은 필요 값을 설정, 표현 된 범위를 변경하려고하지 :

nextRange.Value = new32AField 
+0

당신의 도움에 따라 해결할 수있었습니다! 고마워! – user3167398