Need to Restart an Excel VBA Do...Until Loop -


here's code seek assistance:

for = 1 numplayers     replacementdone = 0     until replacementdone <> 0         replacecards = inputbox("blah...blah")         if replacecards <> 0             replace100 = application.round((replacecards / 100), 0)             if replace100 < 5                 players(i, replace100) = deck(deckindex)                 deckindex = deckindex + 1             else                 msgbox "invalid entry - try again."             end if             replace10 = application.round(application.mod(replacecards, 100) / 10, 0)             if replace10 < 5 , replace10 > replace100                 players(i, replace10) = deck(deckindex)                 deckindex = deckindex + 1             else                 msgbox "invalid entry - try again."             end if             replace1 = application.round(application.mod(replacecards, 10), 0)             if replace1 < 5 , replace1 > replace10                 players(i, replace1) = deck(deckindex)                 deckindex = deckindex + 1             else                 msgbox "invalid entry - try again."             end if         end if     loop next 

at each point if statement untrue , msgbox "invalid entry - try again." appear, want restart do until loop. responses i've seen regarding restarting do until loop address user's code logic rather identifying how restart. appreciated.

one way use "goto" statement, so:

for = 1 numplayers     replacementdone = 0      loopstart:     until replacementdone <> 0         replacecards = inputbox("blah...blah")         if replacecards <> 0             replace100 = application.round((replacecards / 100), 0)             if replace100 < 5                 players(i, replace100) = deck(deckindex)                 deckindex = deckindex + 1             else                 msgbox "invalid entry - try again."                 goto loopstart             end if             replace10 = application.round(application.mod(replacecards, 100) / 10, 0)             if replace10 < 5 , replace10 > replace100                 players(i, replace10) = deck(deckindex)                 deckindex = deckindex + 1             else                 msgbox "invalid entry - try again."                 goto loopstart             end if             replace1 = application.round(application.mod(replacecards, 10), 0)             if replace1 < 5 , replace1 > replace10                 players(i, replace1) = deck(deckindex)                 deckindex = deckindex + 1             else                 msgbox "invalid entry - try again."                 goto loopstart             end if         end if     loop next 

Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

asp.net mvc - Cannot display error message on Editor or EditorFor -

php - Using str_replace to translate a MySQL Table in html -