+ Reply to Thread
Results 1 to 8 of 8

Help with VBA Looping

  1. #1
    Registered User
    Join Date
    03-27-2011
    Location
    Alamogordo, NM
    MS-Off Ver
    Excel 2010
    Posts
    14

    Help with VBA Looping

    Hey All,

    I have to admit... its been a long time since i used excel VBA and I need some assistance if someone would be so kind to help me this evening!

    I got a text file from a database and the info for each record is on 6 rows. Since the data is consistent all the way down, I created a macro with macro builder to save time to move the data exactly where i needed it for the first record... so that all the data i needed was on 1 line instead of 6, then in my macro i deleted the other 5 rows.

    Now I am trying to remember how to loop this... and I cannot remember for the life of me the code i need to add to create the loop before and after the macro code. In short, I am shifting data around and because there will always be a indefinite number of entries, I need my macro to loop until there is no more data.

    I won't bore you with the auto generated macro code because its sloppy and messy and I was trying to save some time by using the macro builder... LOL..

    The first piece of data starts on Row2, column 3. Can anyone help me with a couple of lines of code? Any help would be highly appreciated.

    DC

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help with VBA Looping

    Bore me with the code!
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help with VBA Looping

    Bore us with the code - it'll show us what you are actually doing to move the 6 rows to 1 row.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    03-27-2011
    Location
    Alamogordo, NM
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Help with VBA Looping

    Ok Ok... i will bore you with the code... but remember... I did not hand write this.. LOL

    Please Login or Register  to view this content.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help with VBA Looping

    Here's how I would interpret your code:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-27-2011
    Location
    Alamogordo, NM
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Help with VBA Looping

    You da bomb! That worked perfectly. I have never seen it done that way either...

    I am very grateful for your help!

    DC

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help with VBA Looping

    Try this, it worked on a mocked up version of how I think the data is laid out.
    Please Login or Register  to view this content.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help with VBA Looping

    Yeah, I saw that CStr trick on a recent post on this forum and - You're welcome!

+ 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