Hi everyone, I was wondering whether anybody would please have a look at my code and help me get it to loop (well, at least, I think that's what I want it to do!).

It's a part of a userform that is attached to my primary workbook. That primary part of the code works well (and its about 30 pages long, so hopefully I won't need to post the whole code!). This particular part of the project is meant to be a way to allow users to add related data to another pre-existing workbook my company uses, from within the main window so they don't have to switch out to the other workbook.

For the most part, this secondary part of the code does exactly what I want it to... The document I am trying to add text to is a mail log which is kept in a workbook entitled "Mail Register". The user enters the details of each piece of mail, and presses Add. The Add function adds it to a summary text box (TextBox13), creating tabs between each 'heading' (artificially creating 6 'columns' in TextBox13) and then a new line after the 6th 'column'. When they have logged each piece of mail that they are processing, they can review their entries in the summary text box and then select the "Add to Mail Register" button to open the Mail Register, and post the summary.

The following code is the "Add to Mail Register" button code. It works well, but only for the first entry (obviously because that's all i've asked it to do so far!). But, the number of entries is an unknown, we could get 2 pieces of mail that day, or 20+. What I need it to do is when it gets to "vbNewLine" in the TextBox13 code, to move to the next line in the Mail Register, and add the next six 'columns' and then repeat. The Split code seems to allow it to post in the 6 'columns' I require, but I can't for the life of me figure out how to get it to move to the next blank line in the "Mail Register" workbook after it's added the first 6 text entries. Do I need a loop, or can I somehow make it repeat the Split code when it gets to "vbNewLine" (i.e. create a Split within a Split)?

Please Login or Register  to view this content.

I thought about just having the "Add" button adding each text line to the Mail Register, but it seemed to me to be inefficient to open the "Mail Register" document each time to add one line of text. I thought it better to create a summary of entries, and post them all at once. The "Mail Register" document is used by multiple users, so having it open for the least amount of time would seem to all but avoid potential conflicts arising (though not completely eliminate the possibility; the total potential users are only a handful, so I would think it a rather large fluke if any 2 of those were trying to add to the Mail Register within the 5 odd seconds another was processing the same code from a different computer).

Maybe though, it might be prudent to add another line of code to open a MsgBox telling the user that "Such-and-such-other-user already has this document open, press OK to try again.", though I'm not sure if that's even possible, but if you could consider it in your replies I would much appreciate it. Alternatively, I am open to any other suggestions as to how to achieve the same objective in a more efficient way. I've done a few little VBA projects before but this is by far my biggest and most complex, and I'm a little out of my depth.

Many thanks in advance if anyone can help