VBA find function

Rob Mann

Board Regular
Joined
Jan 10, 2011
Messages
63
below is a copy of some code that searches my database for an entry in column "C". what i want it to do then is to open user form 2 and in the job number text box, i want job number to be already populated. In user form 2 i have 4 other text boxes for the user to populate. I then want those 4 other entries to populate column "F - I"
user form 1 populates columns "a to e" so i want to be able to search column c and populate colums f to i on the same line
any ideas?

Sub Find_Last()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a job number")
If Trim(FindString) <> "" Then
With Sheets("Sheet1").Range("C:C")
Set Rng = .Find(What:=FindString, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Before the End Sub activate the UserForm

UserForm1.Show

Behind the userform on the Activate or Initialize option you can populate the textbox. I have named a text box and told it use the activecell contents. All you have to do then is use the Offset Method to populate the other textboxes.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> UserForm_Initialize()<br>Me.txtProjNumber = ActiveCell.Value<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,203,236
Messages
6,054,298
Members
444,715
Latest member
GlitchHawk

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top