Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-07-2016, 10:20 PM
nachiketapte nachiketapte is offline Macro to split table cells Windows 7 64bit Macro to split table cells Office 2013
Novice
Macro to split table cells
 
Join Date: Mar 2016
Posts: 5
nachiketapte is on a distinguished road
Default Macro to split table cells

I have the below requirement. I have a input similar to this


#


Drawings


Drawing Type


1


Drawing 4, Drawing 27


EC, C





Now I would like to have the output similar to this


#


Drawings


Drawing Type


1


Drawing 4


EC


2


Drawing 27


C



Can some expert help me with this

I found the following piece of code written on one of the forum and thought would be of help to me.
Code:
Sub TableSplitter()
Application.ScreenUpdating = False
Dim Tbl As Table, RngFnd As Range, StrFindTxt As String
StrFindTxt = InputBox(",")
If Trim(StrFindTxt) = "" Then Exit Sub
For Each Tbl In ActiveDocument.Tables
  Set RngFnd = Tbl.Range
  With RngFnd.Find
    .ClearFormatting
    .Text = StrFindTxt
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    Do While .Execute
      With RngFnd.Duplicate
        'The next two lines break the table *after* the found row
        If .Cells(1).RowIndex < .Tables(1).Rows.Count Then
          .Tables(1).Split .Cells(1).RowIndex + 1
        End If
        'The next two lines break the table *before* the found row
        If .Cells(1).RowIndex > 1 Then
          .Tables(1).Split .Cells(1).RowIndex
        End If
        .Collapse (wdCollapseEnd)
      End With
    Loop
  End With
Next
Set RngFnd = Nothing
Application.ScreenUpdating = True
End Sub

Last edited by macropod; 03-07-2016 at 10:31 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to split table cells split row of cells at semicolon lbeck Excel 8 06-06-2015 01:55 PM
how to split merged data into vertical saperate cells cheekugreat Excel 5 10-11-2014 05:53 AM
Macro to loop through all cells in a table produced by a mail merge elh52 Word VBA 4 08-31-2014 10:50 PM
Losing rows when pasting split cells Gitley Word Tables 1 01-15-2013 07:49 AM
Macro to split table cells Macro to Merge Cells Row By Row in a Table KD999 Word VBA 4 02-20-2012 08:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft