danovkos
04-28-2009, 05:38 AM
i try this question on other forum, but nobody there helps me.
http://www.excelforum.com/excel-programming/673435-default-text.html
can anyone help me with this here?
I want to have in my textbox1 always a default text (Text here). After clicking to this textbox it will clear it and it is possible to written and seach names. Ater clicking in other cell or clicking out out this textbox, the default text will appears in textbox again. How can i do it?
here is code:
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Dim i As Long
Dim cell As Range
Dim FirstCell As String
Range("J2").ClearContents
Rem Application.Wait waitTime
If TextBox1.Value = "" Then Exit Sub
If Len(TextBox1.Text) < 4 Then Exit Sub
With Worksheets("2008")
With .Range(.Range("e1"), .Range("e65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
With Worksheets("2007")
With .Range(.Range("a1"), .Range("a65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
With Worksheets("vývoj")
With .Range(.Range("f1"), .Range("f65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
With Worksheets("KK")
With .Range(.Range("f1"), .Range("f65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
End Sub
http://www.excelforum.com/excel-programming/673435-default-text.html
can anyone help me with this here?
I want to have in my textbox1 always a default text (Text here). After clicking to this textbox it will clear it and it is possible to written and seach names. Ater clicking in other cell or clicking out out this textbox, the default text will appears in textbox again. How can i do it?
here is code:
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Dim i As Long
Dim cell As Range
Dim FirstCell As String
Range("J2").ClearContents
Rem Application.Wait waitTime
If TextBox1.Value = "" Then Exit Sub
If Len(TextBox1.Text) < 4 Then Exit Sub
With Worksheets("2008")
With .Range(.Range("e1"), .Range("e65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
With Worksheets("2007")
With .Range(.Range("a1"), .Range("a65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
With Worksheets("vývoj")
With .Range(.Range("f1"), .Range("f65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
With Worksheets("KK")
With .Range(.Range("f1"), .Range("f65536").End(xlUp))
Set cell = .Find(What:=TextBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not cell Is Nothing Then
FirstCell = cell.Address
Do
Range("J2").End(xlUp).Offset(1, 0).Value = cell.Value
Set cell = .FindNext(cell)
Loop While Not cell Is Nothing And cell.Address <> FirstCell
End If
End With
End With
End Sub