Here is my code for the autofilter operation.. Everything works fine, until the user click in the textbox and the text disappears. I wanted the text in the textbox to be locked so that it will not disappears when user clicks the textbox.
Could anyone help me with this? Thanks
If Me.ComboBox2.BoundValue = vbNullString Then
MsgBox "Please select search option !", vbOKOnly
Exit Sub
Else
If Me.ComboBox2.BoundValue = "Date" Then
' If Me.ComboBox1.BoundValue = "Test " Then 'And Me.ComboBox2.BoundValue = "Date" Then
If Me.ComboBox4.BoundValue = vbNullString Or Me.ComboBox5.BoundValue = vbNullString Then
MsgBox "Please select Month & Year!", vbOKOnly
Exit Sub
Else
Sheet2.Range("$P$3:$Q$34").AutoFilter Field:=1, Criteria1:=ComboBox4.Value
Sheet2.Range("$P$3:$Q$34").AutoFilter Field:=2, Criteria1:=ComboBox5.Value
count = 0
Set visrng = Range("A3:A" & Cells(Rows.count, 1).End(xlUp).row).SpecialCells(xlCellTypeVisible)
If (visrng.row < 3) Then
With TextBox1
.MultiLine = True
.FontBold = True
.Text = " No due in this month "
End With
Sheet2.ShowAllData
Else
For Each rw In visrng
row = rw.row
DateArray(count, 0) = count
DateArray(count, 1) = Sheet2.Cells(row, 7)
DateArray(count, 2) = Sheet2.Cells(row, 18)
count = count + 1
Next rw
For i = 1 To 34
out = out & Format(DateArray(i, 0)) & vbTab
out = out & Format(DateArray(i, 1)) & vbNewLine
out = out & vbTab & Format(DateArray(i, 2)) & vbTab & vbNewLine
out = out & vbCrLf
Next i
With TextBox1
.MultiLine = True
.FontBold = True
.Text = "List for the month of " & ComboBox4.Value & " " & ComboBox5.Value & Chr(13) & Chr(13) & out
.ForeColor = &H80000012
End With
Sheet2.ShowAllData
End If
Exit Sub
End If
Bookmarks