Split concatenated text, format then re-concatenate with format

问题描述 投票:0回答:1

the error message is :

Here my code trial :enter image description here Sub SplitConcatenatedString() Dim splitArray() As String Dim i As Integer Set ws = ThisWorkbook.Worksheets("Sheet1") Dim rng As Range Set rng = Range("L5:L" & LastRow()) ' Split the string into an array using the comma as a delimiter For j = 5 To LastRow() With ws.Cells(j, 12) splitArray = Split(.Value, ",") .Offset(0, 1).Value = "" For i = LBound(splitArray) To UBound(splitArray) If Len(splitArray(i)) = 9 Then Call StrikeText_2(ws.Cells(j, 12), splitArray(i)) ElseIf splitArray(i) = "TBA" Then Call StrikeText_1(ws.Cells(j, 12), splitArray(i)) End If .Offset(0, 1).Value = .Offset(0, 1).Value & .Offset(0, 2).vlaue Next i End With Next j End Sub

EDIT : Geert Bellekens pinpointed the syntax error in code line. it is fixed and code worked but format was not copied only value which defeats the main purpose of the code. so the i replaced Value property by Text property but i got another error :

The question how to modify this code line to copy value and format.enter image description here

If you KNOW that the first 9 characters of each cell in that column will be a date, then you can use something like this for your loop.

excel vba
1个回答
0
投票

© www.soinside.com 2019 - 2025. All rights reserved.