+ Reply to Thread
Results 1 to 15 of 15

Do Until.. Loop

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Do Until.. Loop

    The macro first needs to ask for the employers ID number to put in the header row. The valid ID number should be less than 100. If the user enters an invalid ID, the macro continues asking for the ID until it is valid. The macro then asks whether it is night shift. If it is night shift the header background color should be pink, otherwise it should be blue.

    The macro must be primarily hand-coded and include conditional logic, loops, modify data, and user interaction.

    I was able to do everything except the "Do Until..Loop" where I have to put the valid ID number less than 100.
    I did what I can do but failed since I am not so good at this subject. Please help!!
    This is how my VBA looks like.


    Thanks in advance.
    Attached Files Attached Files
    Last edited by kunoichi05; 08-20-2012 at 03:40 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Do Until.. Loop

    in VBA not Do Until..Loop but

    Do
    ------
    loop until condition

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Do Until.. Loop

    Hi, pael45,

    sorry but either a check before the beginning of the first run is possible or after the first run:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  4. #4
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Re: Do Until.. Loop

    the one I'm doing is
    Do Until
    .....
    Loop

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Do Until.. Loop

    try this,

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Do Until.. Loop

    very strange, the first time I tried to run a do until I received error, now it runs

    kunoichi05
    attach please your file with macro
    Last edited by patel45; 08-20-2012 at 04:58 AM.

  7. #7
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Re: Do Until.. Loop

    here you go..thanks for trying!!
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Re: Do Until.. Loop

    JapanDave
    when i did it, after couple of seconds my computer froze and had to close the document.

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Do Until.. Loop

    Two words for you: OPTION EXPLICIT

    You have misspelled your variable - your loop is:
    Please Login or Register  to view this content.
    but your input variable is myEmployeeID

    BTW, this is the Excel programming area, not Word (though that is moot here).
    Remember what the dormouse said
    Feed your head

  10. #10
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Re: Do Until.. Loop

    romperstomper
    thanks for identifying the spelling
    than which site would you recommend for the Word?

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Do Until.. Loop

    The Word Programming area is here.

  12. #12
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Re: Do Until.. Loop

    thanks for the link
    Btw even after correcting the spelling it still didnt work..and is there any way to move this thread to the link you provided me?

  13. #13
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Do Until.. Loop

    Try this. Replace the part of the code down to where you ask if it is night shift or not.
    Please Login or Register  to view this content.
    The working example,
    Attached Files Attached Files
    Last edited by JapanDave; 08-20-2012 at 10:22 PM.

  14. #14
    Registered User
    Join Date
    08-19-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Office Word 97 - 2003 Document
    Posts
    7

    Re: Do Until.. Loop

    Hi JapanDave,
    thank you for reply..as I am a newbie for macros i dont really get which code to replace with the "night shift" and i dont get what "Dim" means..can you please explain in details.
    Last edited by kunoichi05; 08-21-2012 at 08:57 PM.

  15. #15
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Do Until.. Loop

    I was not sure if that workbook was the tone you were working out of. But, the example file I posted has the amended code in it, so you really don't need to do anything. Try that workbook and see if it does what you need?
    "Dim" is used to declare a variable as Romperstaomper earlier pointed out.
    Last edited by JapanDave; 08-21-2012 at 11:06 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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