need help in split macro (VBA)

lynn8566

New Member
Joined
Apr 7, 2011
Messages
18
Dear all

I have a huge amount of conference record which use to write down meeting content, like shown below (sorry I have changed the content)

Excel Workbook
ABCDEHI
4TOPTopicMeeting minutesTyperesponsible/contactuntilattachments & links
5*******
62006-09-011th meeting MV C221 / BCFBuilding 11, 3th floor, room 2.A999****
71requirement sections and responsibilitiesDer Stuttgarter Gemeinderat ist drauf und dran, seine massive Sparpolitik der vergangenen zwei Jahre nachhaltig zu lockern. Manfred Kanzleiter, seit vielen Jahren der SPD-Haushaltsexperte, hatte mit einem Antrag im Februar den Stein ins Rollen gebracht.AAADEGruen2006-09-182006-09-18Requirement_sections
82styling dataDoppelhaushalt fr 2012/13 gehe, so kndigte Manfred Kanzleiter an, werde die st?dtische Personalpolitik "ein zentrales Thema sein".Dieses Glasdach l?sst sich auf Knopfdruck hell oder dunkel schalten. Hell ist es fast v?llig durchsichtig und bietet auch bei kalter Witterung ein Open-Air-Erlebnis.VAAllRot2006-09-222006-09-22*
Sheet1



information in column C to E is correlative.

now we want to separate each records and responsible person to a new row.

here is an example sheet


Excel Workbook
ABCDEFG
1TOPTopicMeeting minutesTyperesponsible/contactuntilattachments & links
2*******
32006-09-011th meeting MV C221 / BCFBuilding 11, 3th floor, room 2.A999****
41requirement sections and responsibilitieDer Stuttgarter Gemeinderat ist drauf und dran, seine massive Sparpolitik der vergangenen zwei Jahre nachhaltig zu lockern.AADE2006/9/18Requirement_sections
51requirement sections and responsibilitieManfred Kanzleiter, seit vielen Jahren der SPD-Haushaltsexperte, hatte mit einem Antrag im Februar den Stein ins Rollen gebracht.AGruen2006/9/18*
62styling dataDoppelhaushalt fr 2012/13 gehe, so kndigte Manfred Kanzleiter an, werde die st?dtische Personalpolitik "ein zentrales Thema sein".VAll2006/9/22*
72styling dataDieses Glasdach l?sst sich auf Knopfdruck hell oder dunkel schalten. Hell ist es fast v?llig durchsichtig und bietet auch bei kalter Witterung ein Open-Air-Erlebnis.ARot2006/9/22*
Sheet2


I have try to use split macro to detect alt+enter in each column, but it is not work properly.

can some one help?

thanks a lot.
 
I think maybe the problem was because that on the column H, the first row maybe without date on it just shift line(alt+ENTER). this makes code cannot split correctly.
many thanks for you concern.

HTML:
<a href="http://www.flickr.com/photos/61434127@N04/5669222997/" title="Flickr 上 lynn85662011 的 2"><img src="http://farm6.static.flickr.com/5026/5669222997_46f150480d.jpg" width="500" height="152" alt="2"></a>
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Excel Workbook
ABCDEHI
4TOPTopicMeeting minutesTyperesponsible/contactuntilattachments & links
5*******
6*******
73Storage of styling data in SmaragdblablablablablablablablablaAAAEckbertEckbertRot2006-09-112006-09-11*
minutes


like this
 
Last edited:
Upvote 0
Hi,

Try this one.

Code:
Sub kTest()
    Dim ka, k(), i As Long, n As Long, c As Long
    Dim x, MT255Chars As String, s As String, j As Long
    Dim cAddr()   As String, m As Long, p As Long
    
    '// User settings
    Const SourceShtName         As String = "Sheet1"
    Const SourceRange           As String = "A:I"
    Const DestShtName           As String = "Sheet2"
    Const DestRange             As String = "A1"
    '//End
    
    With Worksheets(CStr(SourceShtName))
        ka = Intersect(.UsedRange, .Range(CStr(SourceRange)))
    End With
    
    ReDim k(1 To UBound(ka, 1) * 3, 1 To UBound(ka, 2))
    
    For i = 1 To UBound(ka, 1)
        x = Split(NormalizeString(ka(i, 3)), Chr(10))
        For c = 3 To 8
            ka(i, c) = NormalizeString(ka(i, c))
        Next
        For m = 0 To UBound(x)
            n = n + 1
            For c = 1 To UBound(ka, 2)
                Select Case c
                    Case 3 To 8
                        On Error Resume Next
                        s = ""
                        s = Split(ka(i, c), Chr(10))(m)
                        On Error GoTo 0
                        If Len(s) > 255 Then
                            j = j + 1
                            ReDim Preserve cAddr(1 To j)
                            cAddr(j) = Cells(i, c).Address(0, 0)
                            MT255Chars = MT255Chars & "," & s
                        Else 'If Len(s) Then
                            k(n, c) = s
'                        Else
'                            k(n, c) = ka(i, c)
                        End If
                    Case Else
                        k(n, c) = ka(i, c)
                End Select
            Next
        Next
    Next
    If j Then MT255Chars = Mid$(MT255Chars, 2)
    If n Then
        With Worksheets(DestShtName).Range(CStr(DestRange))
            .Resize(n, UBound(k, 2)).Value = k
            If j Then
                ka = Split(MT255Chars, ",")
                For i = 1 To j
                    .Range(CStr(cAddr(i))).Value = ka(i - 1)
                Next
            End If
            On Error Resume Next
            .Parent.UsedRange.Columns(3).SpecialCells(4).EntireRow.Delete
        End With
    End If
End Sub
Private Function NormalizeString(ByVal strText As String) As String
    Dim x, i  As Long, s As String
    
    x = Split(strText, Chr(10))
    For i = 0 To UBound(x)
        'If Len(Trim$(x(i))) Then
            s = s & Chr(10) & x(i) 'Trim$(x(i))
        'End If
    Next
    If Len(s) > 1 Then NormalizeString = Mid$(s, 2)
End Function
 
Upvote 0
Hi,

Try this one.

Code:
Sub kTest()
    Dim ka, k(), i As Long, n As Long, c As Long
    Dim x, MT255Chars As String, s As String, j As Long
    Dim cAddr()   As String, m As Long, p As Long
 
    '// User settings
    Const SourceShtName         As String = "Sheet1"
    Const SourceRange           As String = "A:I"
    Const DestShtName           As String = "Sheet2"
    Const DestRange             As String = "A1"
    '//End
 
    With Worksheets(CStr(SourceShtName))
        ka = Intersect(.UsedRange, .Range(CStr(SourceRange)))
    End With
 
    ReDim k(1 To UBound(ka, 1) * 3, 1 To UBound(ka, 2))
 
    For i = 1 To UBound(ka, 1)
        x = Split(NormalizeString(ka(i, 3)), Chr(10))
        For c = 3 To 8
            ka(i, c) = NormalizeString(ka(i, c))
        Next
        For m = 0 To UBound(x)
            n = n + 1
            For c = 1 To UBound(ka, 2)
                Select Case c
                    Case 3 To 8
                        On Error Resume Next
                        s = ""
                        s = Split(ka(i, c), Chr(10))(m)
                        On Error GoTo 0
                        If Len(s) > 255 Then
                            j = j + 1
                            ReDim Preserve cAddr(1 To j)
                            cAddr(j) = Cells(i, c).Address(0, 0)
                            MT255Chars = MT255Chars & "," & s
                        Else 'If Len(s) Then
                            k(n, c) = s
'                        Else
'                            k(n, c) = ka(i, c)
                        End If
                    Case Else
                        k(n, c) = ka(i, c)
                End Select
            Next
        Next
    Next
    If j Then MT255Chars = Mid$(MT255Chars, 2)
    If n Then
        With Worksheets(DestShtName).Range(CStr(DestRange))
            .Resize(n, UBound(k, 2)).Value = k
            If j Then
                ka = Split(MT255Chars, ",")
                For i = 1 To j
                    .Range(CStr(cAddr(i))).Value = ka(i - 1)
                Next
            End If
            On Error Resume Next
            .Parent.UsedRange.Columns(3).SpecialCells(4).EntireRow.Delete
        End With
    End If
End Sub
Private Function NormalizeString(ByVal strText As String) As String
    Dim x, i  As Long, s As String
 
    x = Split(strText, Chr(10))
    For i = 0 To UBound(x)
        'If Len(Trim$(x(i))) Then
            s = s & Chr(10) & x(i) 'Trim$(x(i))
        'End If
    Next
    If Len(s) > 1 Then NormalizeString = Mid$(s, 2)
End Function


Sorry buddy, its not work, error was "subscript out of range" debug didnt say which line was wrong. help
 
Upvote 0
Hi,

It's working fine here.

In Sheet1:


Excel Workbook
ABCDEFGHI
4TOPTopicMeeting minutesTyperesponsible/contact**untilattachments & links
5*********
6*********
73Storage of styling data in SmaragdblablablablablablablablablaAAAEckbertEckbertRot**2006-09-112006-09-11*
Sheet1



In Sheet2:


Excel Workbook
ABCDEFGHI
1TOPTopicMeeting minutesTyperesponsible/contact**untilattachments & links
23Storage of styling data in SmaragdblablablaAEckbert****
33Storage of styling data in SmaragdblablablaAEckbert**11-09-2006*
43Storage of styling data in SmaragdblablablaARot**11-09-2006*
Sheet2
 
Upvote 0
Ah, i have also tried the worksheet from forum, it really works.

but if the top column was not filled with * marks, if you just delete *, then run the code and it goes wrong.
 
Upvote 0
No, sorry still goes wrong, but i get some idea, we use column D as a standard, if there are 3 character in column D was detected, and there are only 2 date in column H then we insert a "*" in the cell H(x), after that if we split it. it will give a correct feedback, i have tested.

is it possible?
 
Upvote 0
Hi,

What about replacing
Rich (BB code):
x = Split(NormalizeString(ka(i, 3)), Chr(10))

with

Rich (BB code):
x = Split(NormalizeString(ka(i, 4)), Chr(10))
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top