+ Reply to Thread
Results 1 to 3 of 3

Word pulling data from Excel: For-Each loop on read input

  1. #1
    Registered User
    Join Date
    04-10-2014
    Location
    Tallahassee, FL
    MS-Off Ver
    Excel 2010
    Posts
    98

    Word pulling data from Excel: For-Each loop on read input

    I have two documents: A Word document that will be dynamically generated (it will not exist before the macro is run), and an Excel spreadsheet containing the data that will need to be put into it. The macro is in a secondary Word document that will be accessed by multiple users with different computer configurations, so the code needs to remain simple (in terms of libraries and settings). MAIL MERGE CANNOT BE USED IN THIS INSTANCE so don't even suggest it, please.

    I have had issues with Excel pushing the data into Word, so I am having Word pull the data into Excel with greater success, so this code is what is in Word, not Excel.

    Please Login or Register  to view this content.
    Right now, it works, but it will take hundreds of lines of code to finish it.

    After writing the above, it occurs to me that the Worksheet "Grouping with Activity-Included" has all the entries I need to break out in its first column, so if I can write a For-Each specifying that column, and enter in the values pulled from its corresponding column to the right, the code can be much shorter.

    Actual Question:Can someone give me an idea on how to write this For-Each that looks into Excel to find out how many times to iterate?

    Thanks!
    Last edited by Phixer; 06-09-2014 at 04:26 PM.

  2. #2
    Registered User
    Join Date
    04-10-2014
    Location
    Tallahassee, FL
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Word pulling data from Excel: For-Each loop on read input

    Here is what I would like it to do, but something in my syntax is wrong. it stops at the For Each line saying "Type Mismatch":
    Please Login or Register  to view this content.
    Last edited by Phixer; 06-09-2014 at 03:22 PM.

  3. #3
    Registered User
    Join Date
    04-10-2014
    Location
    Tallahassee, FL
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Word pulling data from Excel: For-Each loop on read input

    Here is what is working. I use a For-Next loop instead of a For-Each loop because I know there will never be more than 50 entries in that column, with skipping to the first entry (whatever is after "Program Activity") and not performing the Grand Total or blank fields.

    Please Login or Register  to view this content.

+ 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. Pulling data from another excel file using user input (URGENT)
    By NissanGTR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2012, 12:01 AM
  2. Replies: 1
    Last Post: 04-04-2012, 11:14 PM
  3. Input data into Word through Excel
    By Ismajr in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-13-2010, 10:50 PM
  4. Word userform pulling data from Excel
    By Freaky_zoid in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 04-02-2009, 05:38 AM
  5. How to read data from a file and input that data into excel using vb
    By fuze in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2009, 02: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