Set Focus doesn´t result (???)

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to select a textbox from my form in excel with the command #set focus "but apparently it gives me an error, can someone help me?

Error:

Start_Over.JPG



VBA Code:
Private Sub cmd_Recheck1_Click()
   
    A0r = in_A0r.Value
    A90r = in_A90r.Value
    A_90r = in_A_90r.Value
    A1 = 0
    A2 = A90r - A0r
    A3 = A_90r - A0r
   
    Delta = IIf(Abs(A1) > Abs(A2), A1, A2)
    Delta = IIf(Abs(A3) > Abs(Delta), A3, Delta)
   
    ActiveWorkbook.Sheets("calculation_sheet").Activate
    Range("I6").Select
    P666i = ActiveCell.Value
    Range("I7").Select
    P709i = ActiveCell.Value
    Range("I8").Select
    P710i = ActiveCell.Value
    Range("I9").Select
    P713i = ActiveCell.Value
    Range("J6").Select
    P666r = ActiveCell.Value
    Range("J7").Select
    P709r = ActiveCell.Value
    Range("J8").Select
    P710r = ActiveCell.Value
    Range("J9").Select
    P713r = ActiveCell.Value
   
    ActiveWorkbook.Sheets("start").Activate
    Range("A28").Select
    ReChk = ActiveCell.Value
    Do Until ActiveCell = ""
        ReChk = ReChk + 1
        ActiveCell.Offset(1, 0).Select
    Loop
    ActiveCell = ReChk
    '
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P666i
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P709i
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P710i
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P713i
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P666r
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P709r
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P710r
    ActiveCell.Offset(0, 1).Select
    ActiveCell = P713r
    ActiveCell.Offset(0, 1).Select
    ActiveCell = Delta
           
    ActiveWorkbook.Sheets("calculation_sheet").Activate
    Range("I6").Select
    ActiveCell = P666r
    Range("I7").Select
    ActiveCell = P709r
    Range("I8").Select
    ActiveCell = P710r
    Range("I9").Select
    ActiveCell = P713r
    Range("B18").Select
    ActiveCell = 0
    Range("B26").Select
    ActiveCell = 0
    Range("B33").Select
    ActiveCell = 0
   
    ActiveWorkbook.Sheets("Start").Activate
    Application.ScreenUpdating = True
    Sheets("Calculation_Sheet").Visible = False
    Range("A1").Select
           
    in_A0r.Value = Null
    in_A90r.Value = Null
    in_A_90r.Value = Null
    out_666r.Value = Null
    out_709r.Value = Null
    out_710r.Value = Null
    out_713r.Value = Null
    out_Spread1.Value = Null
   
    in_A0r.SetFocus
  
End Sub


Note: I replaced "Call Me.in_A0r.SetFocus" for " in_A0r.SetFocus" because it didn't work too


Form:

hello.JPG
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Is the control visible and enabled at the time? It appears not (or you're referring to the wrong control).
 
Upvote 0
Can you just amend that last line to this and try the code again:

Code:
With in_A0r
If .Visible And .Enabled then
.SetFocus
Else
msgbox "Enabled: " & .enabled & "; Visible: " & .visible
end if
end with

and then tell us what happens.
 
Upvote 0

Forum statistics

Threads
1,214,824
Messages
6,121,783
Members
449,049
Latest member
greyangel23

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