macro to search with two criteria

auber

New Member
Joined
Nov 18, 2009
Messages
5
Hi friends,
I have big problem, please help me. I am new in excel vba and I am learning.
This is the problem:
I have sheet like this:
<TABLE class=MsoNormalTable style="MARGIN: auto auto auto 4.8pt; WIDTH: 145.5pt; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 width=194 border=0><TBODY><TR style="HEIGHT: 15pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>NumID<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>

</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>NumName<o:p></o:p>

</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>NumPrice<o:p></o:p>
</TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 1"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
12<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>klo1<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 2"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
14<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>pri23<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 3"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
15<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>edi31<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 4"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
19<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>vru5<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 5; mso-yfti-lastrow: yes"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
25<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>klo1<o:p></o:p>

</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR></TBODY></TABLE>
And in VBA I made user form with three textboxes and one button. Now I have to find row in which in column A is something what I enter in textbox1 and in column B is something that I enter in textbox2 (in a same time). In textbox3 I have to enter value which I want to place in column C in row which where is in column A value from textbox1 and in column B value from textbox2. After that I have to click on button and the value have to be entered in specific row which in column A and B fulfil values from textbox1 and 2.
Please help me. I need that code. I try with:
<o:p></o:p>
Private Sub CommandButton1_Click()
Dim FindString As String
Dim rng As Range
<o:p></o:p>
FindString = p1.Value

With Sheets("Sheet1").Range("A:A")
Set rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then

FindString = p2.Value

With Sheets("Sheet1").Range("b:b")
Set rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
rng.Offset(0, 1).Value = p3.Value
Else
MsgBox "Nothing found"
End If
End With
End If
End With
End Sub
<o:p></o:p>
But I didn’t make it.
Here are is an example
In textbox1 I enter 25
In textbox2 I enter klo1
In textbox3 I enter 100
And click, the result have to be like this:
<TABLE class=MsoNormalTable style="MARGIN: auto auto auto 4.8pt; WIDTH: 145.5pt; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 width=194 border=0><TBODY><TR style="HEIGHT: 15pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>NumID<o:p></o:p>

</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>NumName<o:p></o:p>

</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>NumPrice<o:p></o:p>
</TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 1"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
12<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>klo1<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 2"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
14<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>pri23<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 3"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
15<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>edi31<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 4"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
19<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>vru5<o:p></o:p>
</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64></TD></TR><TR style="HEIGHT: 15pt; mso-yfti-irow: 5; mso-yfti-lastrow: yes"><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>
25<o:p></o:p>


</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 49.5pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=66>klo1<o:p></o:p>

</TD><TD style="BORDER-RIGHT: #f0f0f0; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #f0f0f0; WIDTH: 48pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #f0f0f0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=64>100<o:p></o:p>

</TD></TR></TBODY></TABLE>
<o:p></o:p>
Could someone help me please?
 

Akashwani

Well-known Member
Joined
Mar 14, 2009
Messages
2,911
Hi,

I'm going to disappoint you, I'm not an expert,
however I am working on something similar today.

I got the following code from here...
http://www.contextures.com/xlUserForm01.html

I have made a few changes, If your TextBoxes are called...
TextBox1, TextBox2, TextBox3 this may help

Code:
[COLOR=black][FONT=Calibri][FONT=Calibri][SIZE=3][COLOR=black]Private Sub CommandButton1_Click()[/COLOR][/SIZE][/FONT][/FONT][/COLOR]
[COLOR=black][COLOR=#000099][FONT=Courier New]Dim[/FONT][/COLOR][FONT=Courier New] iRow [COLOR=#000099]As Long[/COLOR]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT][/COLOR]
[COLOR=black][COLOR=#000099][FONT=Courier New]Dim[/FONT][/COLOR][FONT=Courier New] ws [COLOR=#000099]As Worksheet[/COLOR]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][COLOR=#000099][FONT=Courier New]Set[/FONT][/COLOR][FONT=Courier New] ws = Worksheets("Sheet1")<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New]<o:p></o:p>[/FONT]
[COLOR=black][COLOR=#006600][FONT=Courier New]'find first empty row in database[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]iRow = ws.Cells(Rows.Count, 1) _<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] .End(xlUp).Offset(1, 0).Row<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[COLOR=black][COLOR=#006600][FONT=Courier New]'check for a NumID[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][COLOR=#000099][FONT=Courier New]If[/FONT][/COLOR][FONT=Courier New] Trim(Me.TextBox1.Value) = "" [COLOR=#000099]Then[/COLOR]<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New][COLOR=black] Me.TextBox1.SetFocus<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] [COLOR=#000099]MsgBox[/COLOR] "Please enter a NumID"<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] [COLOR=#000099]Exit Sub[/COLOR]<o:p></o:p>[/COLOR][/FONT]
[COLOR=black][COLOR=#000099][FONT=Courier New]End If[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New]<o:p></o:p>[/FONT]
[COLOR=black][COLOR=#006600][FONT=Courier New]'copy the data to the database[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]ws.Cells(iRow, 1).Value = Me.TextBox1.Value<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]ws.Cells(iRow, 2).Value = Me.TextBox2.Value<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]ws.Cells(iRow, 3).Value = Me.TextBox3.Value<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[COLOR=black][COLOR=#006600][FONT=Courier New]'clear the data[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]Me.TextBox1.Value = ""<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Me.TextBox2.Value = ""<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Me.TextBox3.Value = ""<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Me.TextBox1.SetFocus<o:p></o:p>[/COLOR][/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[COLOR=black][COLOR=#000099][FONT=Courier New]End Sub[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
Sorry I couldn't be more helpful, good luck.

Ak
 

auber

New Member
Joined
Nov 18, 2009
Messages
5
Dear friend,
Thank you very much, but I think that we are misunderstood.
I want when I enter values in userform in textbox1,2,3 (and click the button) to find the row which in column A have value from textbox1 and in column B have textbox2 and in that row (which has claimed values) in column C fill value from textbox3.
 

Forum statistics

Threads
1,082,323
Messages
5,364,583
Members
400,809
Latest member
formulasataglance

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top