+ Reply to Thread
Results 1 to 6 of 6

Insert Rows in a Dynamic Area and then Add Text to New Rows

Hybrid View

  1. #1
    Registered User
    Join Date
    10-17-2005
    Posts
    27

    Insert Rows in a Dynamic Area and then Add Text to New Rows

    With some searching, I was able to finally get my insert rows function to work. I think I did it messy by adding the insert command 7 times (for the 7 rows I need). Can someone suggest how to do this in one line? I don't mind it messy except I'm going to have to do it again with a few more rows - thus even messier. The idea is for the code to look for the "CONCLUSION" row and insert 7 rows above it. I want the topmost row to be activated which I'll explain further in my second question below.

    HTML Code: 
    Next question is getting the data to fill into the 7 rows. I have a sub called AssignFieldNamesUpdate which has each of the sections and fields defined. Let me know if you need to see it in order to help with my next question. I copied the below code from another area that works correctly. I also made double sure that the arrSectionUpdate(i) is spelled right and all that. I'm getting an error on the Cells(intRowOffset, 1).Value... line below. Any ideas??

    HTML Code: 

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    1)
    cells(h,1).resize(7,1).entirerow.insert
    2) Where is ActiveRow assigned a value? Is it a global variable? What is the value when the error occurs?


    rylo

  3. #3
    Registered User
    Join Date
    10-17-2005
    Posts
    27
    1) Thanks - perfect!

    2) Yes, ActiveRow is global, and in my case it's correctly on row 46 in my test example. The error I'm getting is Run time '1004' - Application-definted or object-defined error. If I pull the array assignment into this sub (instead of calling the separate one), it looks like this:

    HTML Code: 
    And it continues on as already posted above. Thoughts??? I'm stumped...

  4. #4
    Registered User
    Join Date
    10-17-2005
    Posts
    27
    Okay - in thinking about this further, I realized you just hit on my problem. The ActiveRow isn't working like I thought. If I hard code in row 46, it begins working again. So, how can I set intRowOffset to be the row number that is selected or activated?

  5. #5
    Registered User
    Join Date
    10-17-2005
    Posts
    27
    I think I got it!!

    HTML Code: 
    The whole thing works now. Thanks for helping me (eventually) get there!

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    you only need it to be

    intRowOffset = ActiveCell.Row
    Glad you got there in the end. To me helping you to learn, understand and expand on responses, rather than just accepting the code, is a great part of these boards.

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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