+ Reply to Thread
Results 1 to 8 of 8

Loops and Arrays

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

    Loops and Arrays

    Hi I have an XML page for my home web page that has the following lines:

    <image>
    <filename>Wedding_Pictures_001.jpg</filename>
    <caption>Wedding Pictures 001</caption>
    </image>

    I change the Gallery from time to time and at the last count I had 471 images.
    I have concatenated though a spread sheet for some time now and it has been very time consuming.
    So I started to look at recording a macro and have found the process intriguing and very frustrating due to my limitations.
    What I want to do is run the image and caption numbering from _001 to _471. I think this would be simple enough but the books I have been reading are way too advanced.

    Can anyone help?

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loops and Arrays help

    I'm none the wiser. Post a sample workbook which illustrates what you want doing.

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

    Re: Loops and Arrays help

    Hi sorry for not explaining myself properly.

    I want to duplicate the text below from 001 to 471.

    <image>
    <filename>Wedding_Pictures_001.jpg</filename>
    <caption>Wedding Pictures 001</caption>
    </image>
    <image>
    <filename>Wedding_Pictures_002.jpg</filename>
    <caption>Wedding Pictures 002</caption>
    </image>

    Down to
    <image>
    <filename>Wedding_Pictures_471.jpg</filename>
    <caption>Wedding Pictures 471</caption>
    </image>

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loops and Arrays help

    Yes, I understand, but can you post a small workbook showing your data? That way any response will work for your situation.

    EDIT: or you could try this. Replace the second line with this

    ="<filename>Wedding_Pictures_"&TEXT((ROW()+2)/4,"00#")&".jpg</filename>"

    and the third line with this

    ="<caption>Wedding Pictures "&TEXT((ROW()+1)/4,"00#")&"</caption>"

    Select the first four rows and then drag down.
    Last edited by StephenR; 01-29-2010 at 11:05 AM.

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

    Re: Loops and Arrays help

    Sorry I don't know how to post the workbook?

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

    Re: Loops and Arrays help

    Hi I have worked it, sorry new on the forum.

    I want to be able to add say 500 to the code and for the VBA or macro to run down the list?

    I hope this helps
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loops and Arrays help

    Did you try my suggestion?

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

    Re: Loops and Arrays help

    Hi StephenR,

    Yes that would do the tick...and thank you for your help.
    I am sorry as I want to learn about loops and arrays I know it is using a hammer to crack a nut.

    I am trying to learn how this could be done and am struggling a little on the macro side

+ 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