Hi guys,
I have this worksheet that I am working on. It has a userform. When I click thebutton from the worksheet then the userform will pop up. The textbox1 has thisdropdown box where I select the company names. The list of companies has about300 listed.I have to use the down arrow to search each individual from thetextbox1.
Is there anyway that you can edit this code (see below) for me to be able tosearch or looks for words that partially match that is on the list?
Example: General Albertson Gas Company, Gutierrez Gas Tile Company, Marian SaltLite Corp. .... When I search and type Gas then all the one that has word"gas" will be partially be showing so I can select.
Here is the code I have so far.
I have this worksheet that I am working on. It has a userform. When I click thebutton from the worksheet then the userform will pop up. The textbox1 has thisdropdown box where I select the company names. The list of companies has about300 listed.I have to use the down arrow to search each individual from thetextbox1.
Is there anyway that you can edit this code (see below) for me to be able tosearch or looks for words that partially match that is on the list?
Example: General Albertson Gas Company, Gutierrez Gas Tile Company, Marian SaltLite Corp. .... When I search and type Gas then all the one that has word"gas" will be partially be showing so I can select.
Here is the code I have so far.
Code:
Const header = "C12,a ,k22,a ,o22,a ,n23,a,v23,a ,n24,a ,v24,a ,n25,a ,x25,a ,e30,a,e31,a ,d44,a"
Const Secflr = " Address Incomplete.|Appearance date on the citation is not readable.|" & _
" Appearance date on the citation is not valid.| Appearance Date on the citation is/was scheduled on the Holiday.|" & _
"the citation.|You requested that we return thecitation to you.|" & _
""
Const mySheet = "Sheet1"
Private Sub CmdClearEntry_Click()
Dim ct As Control
tmpfmen = ""
tmpcben = ""
For Each ct In Me.Controls
If InStr(ct.Name, "TextBox") > 0 Then
tmpfmen = tmpfmen & ct & "|"
ct = ""
ElseIf InStr(ct.Name, "Textbox") > 0 Then
tmpcben = tmpcben & ct & "|"
ct = ""
End If
Next
tmpfmen = Left(tmpfmen, Len(tmpfmen) - 1)
tmpcben = Left(tmpcben, Len(tmpcben) - 1)
tmpheader = header
tmpmysht = mySheet
headerArr = Split(header, ",")
tmpwken = ""
Set sht = Worksheets(mySheet)
For a = 0 To (UBound(headerArr) - 1) / 2
tmpwken = tmpwken & sht.Range(headerArr(a * 2)) & "|"
sht.Range(headerArr(a * 2)) = ""
Next
tmpwken = Left(tmpwken, Len(tmpwken) - 1)
CmdUndo.Enabled = True
End Sub
Private Sub CmdUndo_Click()
fmen = Split(tmpfmen, "|")
cben = Split(tmpcben, "|")
Dim ctl As Control
For Each ctl In Me.Controls
If InStr(ctl.Name, "TextBox") Then
ctl.Text = fmen(n)
n = n + 1
ElseIf InStr(ctl.Name, "Textbox") Then
ctl.Text = cben(m)
m = m + 1
End If
Next
headre = tmpheader
mySheet1 = tmpmysht
headerArr = Split(headre, ",")
wken = Split(tmpwken, "|")
Set sht = Worksheets(mySheet1)
For a = 0 To (UBound(headerArr) - 1) / 2
sht.Range(headerArr(a * 2)) = wken(n2)
n2 = n2 + 1
Next
CmdUndo.Enabled = False
tmpfmen = ""
tmpcben = ""
tmpwken = ""
End Sub
Private Sub UserForm_Initialize()
If tmpfmen = "" And tmpwken = "" Then
CmdUndo.Enabled = False
Else
CmdUndo.Enabled = True
End If
End Sub
Private Sub CmdCancel_Click()
UnloadMe
End Sub
Private Sub CmdExit_Click()
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub
Private Sub CommandButton1_Click()
If UBound(headerArr) Mod 2 <> 1 Then MsgBox "Error in Cell Address & Header pair"
For a = 0 To (UBound(headerArr) - 1) / 2
Range(headerArr(a * 2)).Offset(0, 1) = InputBox(headerArr(a * 2 + 1), "Field Entry")
Next
End Sub
Private Sub cmdOK_Click()
headerArr = Split(header, ",")
Set sht = Worksheets(mySheet)
For a = 0 To (UBound(headerArr) - 1) / 2
sht.Range(headerArr(a * 2)) = Controls("TextBox" & (a + 1))
Next
End Sub
Private Sub cmdPrint_Click()
ActiveSheet.PrintOut copies:=1
End Sub
Last edited by a moderator: