Hello!
Can somebody help me on this?
I am having hard time to populate text box without using input form.
I want to use input form on worksheet which i used to search data on my worksheets (database 2010,database 2011, database 2012.. etc)
Here is my code using input box which i pasted on standard module.
Code:
Public DSO As Object
Public DstRow As Long
Public DstWks As Worksheet
Public SrcWks As Worksheet
Private Sub FindKeyword(ByVal Keyword As String)
Dim LastRow As Long
Dim Result As Range
Dim Rng As Range
Dim StartRow As Long
StartRow = 2
LastRow = SrcWks.Cells(Rows.Count, "B").End(xlUp).Row
LastRow = IIf(LastRow < StartRow, StartRow, LastRow)
Set Rng = SrcWks.Cells(1, 1).CurrentRegion.Offset(1, 0)
Set Rng = Rng.Resize(Rng.Rows.Count - 1)
Set Result = Rng.Find(What:=Keyword, _
After:=Rng.Cells(1, 1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
A = Rng.Address
If Not Result Is Nothing Then
FirstAddx = Result.Address
Do
If Not DSO.Exists(Result.Row) Then
DSO.Add Result.Row, DstRow
SrcWks.Rows(Result.Row).EntireRow.Copy Destination:=DstWks.Cells(DstRow, "A")
DstRow = DstRow + 1
End If
DstWks.Cells(DSO(Result.Row), Result.Column).Interior.ColorIndex = 6
Set Result = Rng.FindNext(Result)
Loop While Not Result Is Nothing And Result.Address <> FirstAddx
End If
End Sub
Public Sub FindKeywords()
Dim Keys As Variant
Dim Keyword As Variant
Dim Keywords As Variant
Dim Msg As String
Dim R As Variant
Set DstWks = Worksheets("View")
Set SrcWks = Worksheets("Database 2010")
If DSO Is Nothing Then
Set DSO = CreateObject("Scripting.Dictionary")
DSO.Comparemode = vbTextCompare
End If
Msg = "Please enter the keywords below. Separate multiple entries with a comma." _
& " Wildcard characters * and ? can also be included."
Keywords = InputBox(Msg)
If Keywords <> "" Then
DstRow = 21
DstWks.UsedRange.Offset(20, 0).Clear
Keywords = Split(Keywords, ",", Compare:=vbTextCompare)
For Each Keyword In Keywords
FindKeyword (Keyword)
Next Keyword
Else
Exit Sub
End If
Set DSO = Nothing
Set Keywords = Nothing
Sheets("View").Select
Range("a21").Select
End Sub
Here is my work book:
Thank you in Advance!
Bookmarks