title: One word document for each unique cell
body: <p>I have excel tables like below:</p>
  
  <p>column A | Column B | Column C</p>
  
  <p>X         BOB      APPLE</p>
  
  <p>X         BOB      BANANA</p>
  
  <p>X         BOB      PEAR</p>
  
  <p>Y         SARAH    APPLE</p>
  
  <p>Y         SARAH    KIWI</p>
  
  <p>Z         CARL     BANANA</p>
  
  <p>Z         CARL     PINEAPPLE</p>
  
  <p>Z         CARL     WATERMELON</p>
  
  <p>Z         CARL     KIWI</p>
  
  <p>I would like to be able to cycle through column A, for each unique column A value, produce a word document with the value in Column B as the name of the document and Column C as the contents. In the table above, a document titled 'Bob' would contain 'Apple Banana Pear', another document titled 'Sarah' would contain 'Apple Kiwi' , and a third document titled 'Carl' would include 'Banana Pineapple Watermelon Kiwi'.</p>
  
  <p>I've found code, which I've tweaked to my situation, which copies and pastes everything from my Excel into a word document, but this is where I'm stuck. Different excel documents have different numbers of rows, one time it's X, Y, Z in column A, another time, it's V, W, X, Y, Z. I know I'll need to cycle from x = 1 to Len(Cells(x,1)) = 0, but applying this I don't know how. Would appreciate input to my little problem here, and would be interested to learn and understand your reasons.
  Thanks as always. Code:</p>
  
  <pre><code>Option Explicit
  
  
  Sub DataToWord()
  
  
  Dim rng As Range 
  Dim wdApp As Object 
  Dim wdDoc As Object 
  Dim t As Word.Range 
  Dim myWordFile As String 
  Dim x As Long
  
  'initialize the Word template path
  'here, it's set to be in the same directory as our source workbook
  myWordFile = ThisWorkbook.Path &amp; "\Document.dotx"
  
  'get the range of the contiguous data from Cell A1
  Set rng = Range("A1").CurrentRegion
  'you can do some pre-formatting with the range here
  rng.HorizontalAlignment = xlCenter 'center align the data
  rng.Copy 'copy the range
  
  Set wdApp = CreateObject("Word.Application")
  'open a new word document from the template
  Set wdDoc = wdApp.Documents.Add(myWordFile)
  
  Set t = wdDoc.Content 'set the range in Word
  t.Paste 'paste in the table
  With t 'working with the table range
  'we can use the range object to do some more formatting
  'here, I'm matching the table with using the Excel range's properties
  .Tables(1).Columns.SetWidth (rng.Width / rng.Columns.Count), wdAdjustSameWidth
  End With
  
  'until now the Word app has been a background process
  wdApp.Visible = True
  'we could use the Word app object to finish off
  'you may also want to things like generate a filename and save the file
  wdApp.Activate
  
  
  End Sub
  </code></pre>