VBA UserForm Find, Edit

esneaker

New Member
Joined
Feb 1, 2015
Messages
11
Greetings! I am trying to find the best way to utilize my UserForm to find a member, and edit their information (within the found row) based on the values that changed.
---------------------------------------------------------------------------------------------------------------------------
The lookup (for first and last name) function is:
'Col1= First Name
'Col2= Last Name
Function Teach_lookup(Table_Range As Range, Return_Col As Long, Col1_Fnd, Col2_Fnd)

Dim rCheck As Range, bFound As Boolean, lLoop As Long
On Error Resume Next
Set rCheck = Table_Range.Columns(1).Cells(1, 1)
With WorksheetFunction
For lLoop = 1 To .CountIf(Table_Range.Columns(1), Col1_Fnd)
Set rCheck = Table_Range.Columns(1).Find(Col1_Fnd, rCheck, xlValues, xlWhole, xlNext, xlRows, False)
If UCase(rCheck(1, 2)) = UCase(Col2_Fnd) Then
bFound = True
Exit For
End If
Next lLoop
End With
If bFound = True Then
Teach_lookup = rCheck(1, Return_Col)
Else
Teach_lookup = "#N/A"
End If
End Function
---------------------------------------------------------------------------------------------------------------------------
The UserForm pulls from this function to fill the TextBoxes in the UserForm:-
For Instance for bday(TextBox)-

bday = Teach_lookup(Sheets("Master").Range("A:K"), 8, tname.Value, teach_ln)

Here's my question. If I want to edit the teacher's birthdate, how do I change the cell from where the information originated?


Thank you for your time!!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try this:

Code:
[COLOR=#0000ff][B]Set[/B][/COLOR][COLOR=#333333] rCheck = Table_Range.Columns(1).Find(Col1_Fnd, rCheck, xlValues, xlWhole, xlNext, xlRows, [/COLOR][B][COLOR=#0000ff]False[/COLOR][/B][COLOR=#333333])

rcheck.Value ="Your New Value"
[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,216,153
Messages
6,129,179
Members
449,491
Latest member
maxim_sivakon

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