PaSha
11-20-2007, 01:06 PM
Hey guys...:think::think::think:
ahmm hope i don't bother to much ...
but i was traying to do something and i can't get it work without any error's ... so if someone could help me ...
this has also something to do with what xld said... about that prompt MsgBox when the user was traying to click on a button in some short interval...
i got some new task, which is a little bit more complicated... i had to do:
when a user was clicking on a button, the value of that cell would increase for 1... and now i would need this: when he clicks, that value increases, and a InputBox opens in which the user puts a specific code of that produkt which then goes in a special workbooks, sheet, and column... so i have managed that... you can see this here:
Private Sub CommandButton1_Click()
Worksheets("PONEDELJEK-Montag").Unprotect Password:="myPass"
Static LastPress As Double
If Now > LastPress + TimeSerial(0, 0, 7) Then
LastPress = Now
a = Range("i7").Value + 1
Range("i7").Value = a
Dim NextRow As Long
Dim Entry1 As String
' Determine next empty row
NextRow = Workbooks("ProduktNumern.xlsx").Sheets("Produkt numer").Columns("A").Cells(Rows.Count, 1).End(xlUp).Row + 1
' Prompt for the data
Entry1 = InputBox("Vpi?ite ?tevilko produkta")
' Write the data
Workbooks("ProduktNumern.xlsx").Sheets("Produkt numer").Columns("A").Cells(NextRow, 1) = Entry1
End If
Worksheets("PONEDELJEK-Montag").Protect Password:="myPas"
End Sub
this works great ...
but
what i need are the code for some special if stuff...
1. that the user can only type a 10 numeric nummber...when he types more or less the Input Box would prompt him...
Something code like this :
Sub GetValue3()
Dim Entry1 As Variant
Dim Msg As String
Msg = "Enter a 10 numeric value"
Do
UserEntry = InputBox(Msg)
If UserEntry = "" Then Exit Sub
If IsNumeric(UserEntry) Then
If UserEntry = 10 Then Exit Do
End If
Msg = "Your previous entry was INVALID."
Msg = Msg & vbNewLine
Msg = Msg & "Enter a 10 numeric value"
Loop
End Sub
but i can't get to work this when i put this code in the previous code, which already works fine...
2. also what i was traying to do is when a user clicks that button, and the value increases by 1 and a inputboxx come up to put some numer in... when the user diesn't types nothing and clicks ok... my value is still increased by 1 ... how can i do this back in that case??
and also when the user clicks on Cancel the same happens ??
i think this could be done something code like this one:
Sub GetValue2()
Dim Entry1 As Variant
UserEntry = InputBox("Enter the value")
If UserEntry <> "" Then (and so on )
End Sub
i know this is a hell about of code, i know how i could do this but i can't get this done, i neerprogramed in VBA i'm used to do that in c++ and so on...
this is my first week in VBA & excel...
so if someone yould help me ... i know this is :doh:but maybe for someone it isn't...
so i thank you already...
ahmm hope i don't bother to much ...
but i was traying to do something and i can't get it work without any error's ... so if someone could help me ...
this has also something to do with what xld said... about that prompt MsgBox when the user was traying to click on a button in some short interval...
i got some new task, which is a little bit more complicated... i had to do:
when a user was clicking on a button, the value of that cell would increase for 1... and now i would need this: when he clicks, that value increases, and a InputBox opens in which the user puts a specific code of that produkt which then goes in a special workbooks, sheet, and column... so i have managed that... you can see this here:
Private Sub CommandButton1_Click()
Worksheets("PONEDELJEK-Montag").Unprotect Password:="myPass"
Static LastPress As Double
If Now > LastPress + TimeSerial(0, 0, 7) Then
LastPress = Now
a = Range("i7").Value + 1
Range("i7").Value = a
Dim NextRow As Long
Dim Entry1 As String
' Determine next empty row
NextRow = Workbooks("ProduktNumern.xlsx").Sheets("Produkt numer").Columns("A").Cells(Rows.Count, 1).End(xlUp).Row + 1
' Prompt for the data
Entry1 = InputBox("Vpi?ite ?tevilko produkta")
' Write the data
Workbooks("ProduktNumern.xlsx").Sheets("Produkt numer").Columns("A").Cells(NextRow, 1) = Entry1
End If
Worksheets("PONEDELJEK-Montag").Protect Password:="myPas"
End Sub
this works great ...
but
what i need are the code for some special if stuff...
1. that the user can only type a 10 numeric nummber...when he types more or less the Input Box would prompt him...
Something code like this :
Sub GetValue3()
Dim Entry1 As Variant
Dim Msg As String
Msg = "Enter a 10 numeric value"
Do
UserEntry = InputBox(Msg)
If UserEntry = "" Then Exit Sub
If IsNumeric(UserEntry) Then
If UserEntry = 10 Then Exit Do
End If
Msg = "Your previous entry was INVALID."
Msg = Msg & vbNewLine
Msg = Msg & "Enter a 10 numeric value"
Loop
End Sub
but i can't get to work this when i put this code in the previous code, which already works fine...
2. also what i was traying to do is when a user clicks that button, and the value increases by 1 and a inputboxx come up to put some numer in... when the user diesn't types nothing and clicks ok... my value is still increased by 1 ... how can i do this back in that case??
and also when the user clicks on Cancel the same happens ??
i think this could be done something code like this one:
Sub GetValue2()
Dim Entry1 As Variant
UserEntry = InputBox("Enter the value")
If UserEntry <> "" Then (and so on )
End Sub
i know this is a hell about of code, i know how i could do this but i can't get this done, i neerprogramed in VBA i'm used to do that in c++ and so on...
this is my first week in VBA & excel...
so if someone yould help me ... i know this is :doh:but maybe for someone it isn't...
so i thank you already...