+ Reply to Thread
Results 1 to 3 of 3

Insert a number of rows based on the value in a cell

  1. #1
    Registered User
    Join Date
    11-07-2011
    Location
    Texas, US
    MS-Off Ver
    Excel 2007
    Posts
    8

    Question Insert a number of rows based on the value in a cell

    I just recently discovered this forum. It's wonderful to find a place with so many people willing to share their knowledge! I tried other forums before but couldn't get a reply from anyone.

    I need help with the attached document!

    1. It is a Document Change form with tables in Word 2007. I separated all the tables instead of having one long one in Section 1 because I thought it might be easier to work with using code. Is this a good assumption or does it even matter?

    2. In Section 1a, the user will input a number "n" into the cell after "Number of affected documents:" I need to have word automatically insert "n-1" rows (including the content control) at the end of that table. As the "Doc. Number' in the "n" rows are populated, I need the tables 1b - 1e to have "n" rows added to their last row and to have the same "Doc. Numbers" populate in the first cell of each added row.


    3. I've been tasked w/creating multiple documents and I'm trying to learn VBA as I go, How are cells from Word tables referenced in code? For example, if I'm referring to the cell in the 3rd row and the 2nd column in one of the tables, how would that be designated?

    Thanks so much in advance!
    Sandra
    Attached Files Attached Files
    Last edited by garridosk; 11-18-2011 at 06:44 PM. Reason: Number questions

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Insert a number of rows based on the value in a cell

    First question:

    Please Login or Register  to view this content.

    Last question:

    reading:
    Please Login or Register  to view this content.
    writing
    Please Login or Register  to view this content.
    Last edited by snb; 11-16-2011 at 03:45 PM.



  3. #3
    Registered User
    Join Date
    11-07-2011
    Location
    Texas, US
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Insert a number of rows based on the value in a cell

    Thanks for your response. I tried it 2 ways but it didn't do anything.

    I clicked "Design Mode" -> "Visual Basic" -> "This document". There was a window with a previous macro "SAVE1" for saving the document to 2 different files that I had created. Under that window was another window that was empty. I pasted the code in the empty window, closed the VBA window, got out of design mode, saved the file as a macro enabled Word doc. When I typed "5" into the cell to the right of the one with "Number of affected documents" and tabbed, nothing happened. The second time I tried it, I pasted the code into the same window with the "SAVE1" macro. I removed the "End Sub" and pasted it at the end of theat code. It still didn't do anything. Am I doing something wrong?

    I don't understand part of your answer to my last question. What is "c01=activedocument.Tables." ? Does that designate the 1st table in the document? What does "text="example" & chr(8)" mean/do? What is the "(8)" for?

    Sandra

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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