+ Reply to Thread
Results 1 to 21 of 21

Print Excel records to Word?

  1. #1
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Question Print Excel records to Word?

    I have a database in excel.
    It has 40000 records.
    But to make my question simple I use a smaller example to describe my problem.
    In Database.xlsx I have two columns.
    Some of the records have equal value in column A.
    Values in column B are unique.
    I need a way to search and fine records which have same value in column A and then print those records to a word file.

    Here is what I want :

    Database.xlsx :
    A B
    22 1
    22 2
    22 3

    36 4
    36 5
    36 6

    51 7
    51 8
    51 9
    51 10

    ///////////////////////////
    Word01.docx
    Column A : 22
    Column B is from 1 to 3
    Total Numbers of records : 3
    ///////////////////////////
    Word02.docx
    Column A : 36
    Column B is from 4 to 6
    Total Numbers of records : 3
    ///////////////////////////
    Word03.docx
    Column A : 51
    Column B is from 7 to 10
    Total Numbers of records : 4

    Thanks in advance
    Attached Files Attached Files
    Last edited by 5arid; 12-31-2018 at 01:07 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    Have you considered using the mail merge functionality in Word?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    Very useful suggestion thanks.
    But my records in the original Excel file doesn't have any info about total number of the records which have the equal value.
    So first of all I have to edit the Excel file to add a record with that kind of info.
    Here is what I mean :

    Database.xlsx :
    A----B
    22---1
    22---2
    22---3
    36---4
    36---5
    36---6
    51---7
    51---8
    51---9
    51---10

    Should be turns into this :
    A-------B-------C
    22----1 to 3----3
    36----4 to 6----3
    51----7 to 10---4

    Then I can use mail merge functionality in Word.

    But how can I do it with Excel file?
    Search the records which have the same values on column A and then make only one record for that group
    Also a new column C is for the number of records on that group.
    But how?

  4. #4
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    OK I found out how to add C column :
    =COUNTIF(A:A;A1)
    Then I can apply it to the whole column with this method :

    Select a range of cells (the entire column in this case), type in your formula, and hold down Ctrl while you press Enter. This places the formula in all selected cells.
    So now how to make B column which seems more challenging?

    Edit :

    This seems better :
    A-----B---C----D
    22----1---3----3
    36----4---6----3
    51----7---10---4

    Column B is the value of first match
    Column C is the value of last match
    How can I find the first and the last match when I count?
    Last edited by 5arid; 12-30-2018 at 02:23 PM.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    Does the attached help
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    Again thanks
    But I don't get it how does it work?
    Can you explain it?
    Using SUM function? It doesn't make sense.
    Also I have to apply it to a file with 4000 records!

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    You just need to copy F4:H4 down as far as necessary until you run out unique values in column F

    Since column H tells you how many numbers for each column F value it follows that the sum of all the numbers before will give you the secon bit of the column G value, i.e. the "to..." bit.

  8. #8
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    Again thanks
    But I don't get it how does it work?
    Can you explain it?
    Using SUM function? It doesn't make sense.
    Also I have to apply it to a file with 4000 records!

    Edit :
    No need to directly reduce the whole records.
    I think this is better : After adding the info to each record I think it is possible to delete the duplicate records.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    ..and how many unique records are there in the 4000? It hardly takes much longer to copy down say 1000 rows as to copy to 100 rows.

    Why do you say the SUM doesn't make sense. The second number in the "B" column is by definition the sum of all the count of all the prior numbers.
    If you are saying it's wrong then please expalun what you expect to see.

    Otherwise you'll need a macro to completley automate it.

  10. #10
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    At the moment all of the records are unique I am trying to find a way to delete the unnecessary records.
    Sorry I didn't notice that you used a more complicated formula on first column.
    Can you help me to make a formula for columns From and To?
    Sorry to bother you
    Attached Images Attached Images

  11. #11
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Print Excel records to Word?

    With an ordinary Word mailmerge, you can have Word sort the records so that like records appear together. Once the document is connected to the data source, see Mailings|Edit Recipient List>Sort.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    This is getting confusing

    Your OP mentioned wanting a table of the unique values from column A which is what my offering gave you.
    You now seem to want to generate the same From/To values for each number in the list.But to what end if at the end youre going to get rid of the duplicates anyway.

  13. #13
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    I'm sure I can handle it.
    Just give me a formula for column From and another formula for column To.
    Also :
    From is the first match
    To is the last match

  14. #14
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Print Excel records to Word?

    If all you want to do is identify duplicates, there are quite simple ways within Excel itself, including when the test requires comparing multiple columns.

  15. #15
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    Which table of original data are you referring to. The Result table you showed in post#1 or the Original Data Table in post #10?

    The goal post seems to be moving a bit and I'm no longer sure whether you're looking for a unique set of the basic numbers and the associated From/To numbers.

  16. #16
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    Just please help me with post 10

  17. #17
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Print Excel records to Word?

    So what constitutes an 'unnecessary record'?

  18. #18
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    I have to merge a group of records into one record and then delete the extra ones which will be unnecessary record.
    I hope this makes sense :
    I need to turn table 1 into table 2
    And then turn table 2 into table 3
    Then I can use mail merge functionality in Word with table 3
    Attached Images Attached Images
    Last edited by 5arid; 12-30-2018 at 05:13 PM.

  19. #19
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    Quote Originally Posted by macropod View Post
    So what constitutes an 'unnecessary record'?
    A good question.
    So far I'm assuming an unnecessary record is any record which has a value in the column labeled A in post#10 that is the same as an earlier record.

  20. #20
    Registered User
    Join Date
    12-30-2018
    Location
    iran
    MS-Off Ver
    2007
    Posts
    10

    Re: Print Excel records to Word?

    Thanks to all my problem is solved.
    The solution was tooooo easy!
    Starting from post 4 I went into the wrong direction.
    No need to use complicated macros or even no need for COUNTIF!
    It can be done by using - and +
    Here is a quick note on how to do it :
    Delete duplicate records on Column A --> Data > Data Tools > Remove Duplicates
    Column From ---> Column B
    Column To ---> =B3-1 (Next From - 1)
    Column Total --> =C2-B2+1 (To - From + 1)
    Attached Files Attached Files
    Last edited by 5arid; 12-31-2018 at 01:13 AM.

  21. #21
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Print Excel records to Word?

    Hi,

    Glad you came to a satisfactory result and hanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Print Word letters using Excel VBA
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2015, 06:01 AM
  2. Display excel records in Word document
    By tarpitman in forum Excel General
    Replies: 1
    Last Post: 08-16-2011, 07:12 AM
  3. Print word docs via Excel VBA
    By Ducatisto in forum Excel General
    Replies: 3
    Last Post: 04-22-2010, 03:15 AM
  4. Has anyone ever validated Excel or Word for Quality Records?
    By Tanya Crivello in forum Excel General
    Replies: 0
    Last Post: 06-15-2006, 05:00 PM
  5. [SOLVED] excel * word won't print
    By Cimarron in forum Excel General
    Replies: 0
    Last Post: 05-30-2006, 05:10 PM
  6. Replies: 5
    Last Post: 04-06-2006, 09:50 AM
  7. Replies: 1
    Last Post: 11-02-2005, 06:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1