How do I SetFocus on TextBox5 when OK ?

Big Lar

Well-known Member
Joined
May 19, 2002
Messages
557
Code:
[FONT=Verdana]Private Sub TextBox10_Change()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT]
[FONT=Verdana]<o:p></o:p>[/FONT]
[FONT=Verdana]If Trim(Me.TextBox10.Value) = -4 Then<o:p></o:p>[/FONT]
[FONT=Verdana]If MsgBox(Prompt:="Check for $5 Bill in $1 Stack.", Buttons:=vbOKCancel) = vbOK Then<o:p></o:p>[/FONT]
[FONT=Verdana]Exit Sub<o:p></o:p>[/FONT]
[FONT=Verdana]Else<o:p></o:p>[/FONT]
[FONT=Verdana]End If<o:p></o:p>[/FONT]
[FONT=Verdana]End If<o:p></o:p>[/FONT]
[FONT=Verdana]<o:p></o:p>[/FONT]
[FONT=Verdana]End Sub<o:p></o:p>[/FONT]
Suggestions for better code is appreciated, too.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try

Code:
Private Sub TextBox10_Change()
If Trim(Me.TextBox10.Value) = -4 Then
    If MsgBox(Prompt:="Check for $5 Bill in $1 Stack.", Buttons:=vbOKCancel) = vbOK Then
        TextBox5.SetFocus
    End If
End If
End Sub
 
Upvote 0
Peter,

Thanks for the code. I've tried it and the result...

Clicking OK clears the msgbox which then immediately reappears...3 times.
After the 3rd click the msgbox clears and focus is set to TextBox6.
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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