Loop Through UserForm For Multiple Different Outputs

G

gims289

I have a UserForm that I want to repeat so I can get different user input. I
want the input from the UserForm to write into a spreadsheet, then re-open
the UserForm to get different user input and display after the previous
input.

Does anyone know of a way to pause the code while the UserForm is being
populated, then have the code continue from where it left off?
 
G

gims289

That is pretty much what I have, however, my userform is the last of 4
different, connected userforms that are used to gather information. This
part of the data collection may have different inputs, but I can't continue
on until the different inputs are complete. As you can see w/ the code
pasted below, when I click the Next button on the userform, the loop starts
over and never completes. I need a way to continue the loop w/out hitting
the same button that executes the loop.

Public Sub btnNextRate_Click()

NextNumberRow = Cells(1, 1)
StructureLoopCount = 1
Do Until StructureLoopCount = HowManyStructures 'declared earlier
Call RateStructure
Unload RatesForm
RatesForm.Show
StructureLoopCount = StructureLoopCount + 1
NextNumberRow = NextNumberRow + 1
Cells(1, 1) = NextNumberRow
Loop
 
D

Dave Peterson

I really don't understand what the question is, but maybe you could a loop
within the loop.

Do until ...
'a bunch of code
do
'more code
loop
loop
 
G

gims289

Sorry, I'm having a hard time explaining it to myself as well. I need a way
to pause the execution of the code, re-enter different data, then have the
code continue on from there. I need this to happen in the same procedure.
Using a command button to continue forces the code to begin in another
procedure. The loop w/in a loop doesn't help because I still need a way to
continue after re-entering the new data.
 
D

Dave Peterson

I know I could get values using an inputbox. I'm not sure why you can't
retrieve values from the userform.
You could either just hide the form and refer to the values for the controls in
that userform or use public variables and have the userform's code populate
those public variables. Then use those public variables in the code that
continues.

But I'm just guessing. I'm not sure if this helps or not--but I'm betting money
Sorry, I'm having a hard time explaining it to myself as well. I need a way
to pause the execution of the code, re-enter different data, then have the
code continue on from there. I need this to happen in the same procedure.
Using a command button to continue forces the code to begin in another
procedure. The loop w/in a loop doesn't help because I still need a way to
continue after re-entering the new data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top