Is it possible to loop a userform more than once and disabling certain controls on the second loop

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
[COLOR=#333333]Sub splitLot()[/COLOR]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">    
    i = 0
    ansSplit = 0
    
    ans = MsgBox("Is this a split Lot?", vbQuestion + vbYesNo, "Split Lot")
    
    If ans = vbNo Then
        frmPackageYield.Show vbModeless
    Else
        ansSplit = InputBox("How many times does this lot split?", "Split Lot")
        For i = 1 To ansSplit
            If i = 1 Then
                frmPackageYield.Show vbModeless
            ElseIf i > 1 Then
                frmPackageYield.Show vbModeless
                frmPackageYield.TxtBxBlkBlnd.Enabled = False
            End If
        Next i
    End If
    MsgBox "All Done" 

</code>End Sub[COLOR=#222222][FONT=Verdana]

[/FONT][/COLOR]How can I make the above code to loop the form frmPackageYield a certain amount of times determined by ansSplit but on the second loop make certain text boxes disabled. Once all the looping is done display the message box. The problem that I am having is that it loops through so fast then displays the message box the same time the form is loaded for the first time. I hope this explanation makes sense.

Thank You
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I don't have the coding answer but if you open Excel in VBE mode you can use the "F8" Function key to step through your code. You will see each line being accessed as you go. I hope that helps.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top