View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Martin Fishlock Martin Fishlock is offline
external usenet poster
 
Posts: 694
Default Looping with Userform

Les,

Forms work on events like a button click. So you need to put the code for
adding an item on the enter button. (that is in the form designer double
click on the enter button and enter the code for adding the item.

On the finished button double click it and enter the me.hide to hide the form.


You will probably need some global variables to remember where you are and
for set up keep the global variables in a module and define them as public.

Put the initialization code in the form_initialize that can be fould in the
code designer and pulling down one of the combo boxes at the top.

If you need any more help post your code.

Good luck.



On
--
Hope this helps
Martin Fishlock


"WLMPilot" wrote:

I am new to userforms. I have developed a spreadsheet that users will use to
request supplies. I have a userform that the user will enter an item number
and quantity needed. This userform has two command buttons:
(cmdbutton1)=ENTER and (cmdbutton2)=FINISHED.

I tried to set up a Do-While loop w/ condition Do While CommandButton2 <
True in an effort to allow user to enter items until FINISHED was clicked.
After the user clicked ENTER, the code will place place the itemnum & qty in
the appropriate cells. There will also be a check that the user entered a
valid item number.

Problem is I cannot get the loop to work for some reason. Right now, I can
enter an item number and qty, then click ENTER. However, nothing happens.
Is there a better way to do this. I may have to go to a For-Next loop in
order to increase the value in the OFFSET command so that the cursor will
advance to the next line. I also realize that I can just have a variable
increase by 1 within the Do-While loop.

Thanks,
Les