+ Reply to Thread
Results 1 to 7 of 7

Add new Row in Loop

  1. #1
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Add new Row in Loop

    Hi All

    Brilliant I can now add text in front and behind the Loop.
    I now wonder is it possible to add Text in the row above and below the loop can this be done? Like below?

    Image
    Test 1 Test
    Image/
    Image
    Test 2 Test
    Image/


    Please Login or Register  to view this content.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Add new Row in Loop

    If you just add in the command, you will see the word "Image" writes over your other cells:

    Please Login or Register  to view this content.
    Best to hit only every 3rd row:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: Add new Row in Loop

    Hi Dave,

    Thank you for your help we are almost there the only issue is that the Step 3 makes the count go up in 3s.

    Any way we can have the numbers go up in 1s instead of multiples of 3 ?

    Result from code:

    Image
    Test 2 Test
    Image/
    Image
    Test 5 Test
    Image/

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Add new Row in Loop

    Step by 1 is the default, so you don't even need to include it. See the first section of code I posted.

    The only issue is that if you go down one row and post "Image" to the previous row, it will overwrite what you had just written there previously.

    Run the first bit of code and you'll see what I mean.

    Does that help?

  5. #5
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: Add new Row in Loop

    Hi davegugg,

    I added another line on the top and it worked to my surprise.......thank you.

    How do you add an inputbox to add the X= 2 to 100?

    Say I want 10 images so the inputbox would say "How many images to be added?"

    The user inputs 10, the code should calculate 10*3 (+1 for the topline) = 31 and then adds X = 2 to 31? Can this be done?


    Please Login or Register  to view this content.

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Add new Row in Loop

    Ahh, I see why you wanted to step 1. Instead of using a counter, you could switch this line:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.


    Either way, you can get the number of images like this:

    Please Login or Register  to view this content.
    Please note I used integer as the data type for intNumber. If they enter a decimal number or a letter into the input box, an error will occur. (Which makes since because they must add a whole number of images.)
    Last edited by davegugg; 02-02-2010 at 04:48 PM.

  7. #7
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: Add new Row in Loop

    Hi davegugg,

    Fantastic it works thank you.

    I will have a play with the loops and the inputBox now thanks again...

    Solved

+ 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