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:
NumID NumName NumPrice
12 klo1
14 pri23
15 edi31
19 vru5
25 klo1
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:
But I didn’t make it.Code:Private Sub CommandButton1_Click() Dim FindString As String Dim rng As Range 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
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:
NumID NumName NumPrice
12 klo1
14 pri23
15 edi31
19 vru5
25 klo1 100
Could someone help me please?
One more time, 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.
Last edited by auber; 11-18-2009 at 10:42 AM. Reason: mistake
Sorry, my mistake, i will have put tags around code now.
AAAAAAAAAAARAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaaaagrgarggrggrgraghaghr
What lovely code.
Use autofilter.
Record a macro of applying autofilter, then specifying a criterion for columns A and B, then simply use .end(xlup/down) type statements to overwrite column C with the appropriate variable.
This will be about a gazillion times faster - roughly
CC
Than you that was superb hint. It helps me.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks