PDA

View Full Version : inputBox default input in code, user not input



xman2000
04-20-2017, 02:21 PM
Hi, Partners,

i want a InputBox that not shows the screen msgbox, only exists in code, his "user value" is entered in code vba and not by user in worksheet.
i need too other option instead InputBox.

i try ForNext and not works.

the problem is: I need restart the code in a loop, increases the value of "4 to 125" (4 to 4), (5 to 5) , (6 to 6) etc.

the array Array(1) have a error " Run-time error '57121': Application-defined or object-defined error"

thanks!

xman2000
04-20-2017, 03:44 PM
.
like this: i define the value (answer of the user) of Inputbox = 4, then, the vba code simulate click on button "OK" then que answer of the user is number "4".
this trick is a workaround to update the value of inputbox and not show the Msbox of Inputbox.


How can I do this ??

xman2000
04-21-2017, 08:16 AM
Hi,

Like TimeOut, Temporized Inputbox, not other, only Inputbox.


Automatically answer "Yes" to DefaultValue without shows the screen of Inputbox.
The time will be very very small.

i read about Application.ScreenUpdating = True and Application.DisplayAlerts = False

like this code, but in same procedure (Sub) :

by Mikerickson
'http://www.vbaexpress.com/forum/showthread.php?15820-Inputbox-amp-Time



Sub mainRoutine(Optional skipFirstPart As Boolean)

If skipFirstPart Then GoTo endHalf

Rem some code

Application.OnTime Now + TimeValue("0:0:30"), "Skipper"
UserInput = Application.InputBox("enter something")
Application.OnTime proceedure:="Skipper", schedule:=False

endHalf:
Rem more code
End Sub

Sub Skipper()
Call mainRoutine(True)
End
End Sub




edit: look i edited the post.

xman2000
04-21-2017, 12:50 PM
http://www.vbaexpress.com/forum/editpost.php?do=editpost&postid=360092


proceedure =procedure

Logit,

yes, i fix this mistake, but gives other error "argument is not optional" (free translating of Portuguese) in this line: Application.OnTime

if fix this with put the time after Ontime, and stop the error message.
but i not make this work.

i need return the answer of Inputbox.
i set automatically answer to number value:"4" and i need return this value in a variable long.

Logit, please, help me in my Thread:
http://www.vbaexpress.com/forum/showthread.php?59240-inputBox-default-input-in-code-user-not-input


attached sample file

18990


18989

xman2000
04-21-2017, 02:28 PM
Hi, mikerickson,

ok, you maybe help me on my thread in link above.
in your code, not shows the Inputbox like the OP speak in first post. I not understand.

i need invoke the INputbox to erase (re-start) only 1one variable of array afther Redim.
i need increases the value of one ForNext Loop (1 to 125) and clean the variable to re-start in 2 (not preserve first 1)
If i only change the value (1 to 2, 2 to 2 , etc ) adn click on commandbutton in worksheet the code runs ok.
but if i use 1 to 125 gives error.

i think if i invoke inputbox and this uptade the code will clean old value of ForNext in the Array and will works.

thanks.

xman2000
04-21-2017, 03:05 PM
Logit, thanks very, very mutch.
i consider using this userform if I do not find another solution.
I really consider use it
But I still want to try another more practical way that every time I need to create or find a userform.


I am preparing a sample file with my original code.
Maybe I do not prevail on an Inputbox but rather just referesh the code, problem i need refresh the code with new value (increment the value in start the code , like 1 , 2, 3, 4, etc.

look:
''----------------------------------------------
http://www.vbaexpress.com/forum/showthread.php?15820-Inputbox-amp-Time
Hi, mikerickson,

ok, you maybe help me on my thread in link above.
in your code, not shows the Inputbox like the OP speak in first post. I not understand.

i need invoke the INputbox to erase (re-start) only 1one variable of array afther Redim.
i need increases the value of one ForNext Loop (1 to 125) and clean the variable to re-start in 2 (not preserve first 1)
If i only change the value (1 to 2, 2 to 2 , etc ) adn click on commandbutton in worksheet the code runs ok.
but if i use 1 to 125 gives error.

i think if i invoke inputbox and this uptade the code will clean old value of ForNext in the Array and will works.

thanks.

edit: i not understand Inputbox not shows.
edit: Mike, please a sample file with your code like your think, please, i think will help me.