PDA

View Full Version : Solved: Save Data Based on Vlookup



Bopo2
11-01-2009, 08:12 AM
Hey guys

A quick question, basically I'm using several vlookups to populate text boxes on my form with data, however once the user has editted that data, I want the values within the text boxes to save to the cell within the worksheet that they were first retrieved from.

For example

Me.txtname.Text = Application.VLookup(storeId, Worksheets("Customers").Range("CustomerRecords"), 2, 0)
Then when I click the save button, I want the value within the text box to be saved within the original cell. I gave this a try, obviously it didn't work.

Private Sub btnsave_Click()
Application.VLookup(storeId, Worksheets("Customers").Range("CustomerRecords"), 2, 0) = Me.txtname.Text
End Sub
Help appreciated.

lucas
11-01-2009, 10:28 AM
Is it one cell on customers worksheet?

can you post an example?

Bopo2
11-02-2009, 07:00 AM
EDIT:

Woot figured out a solution

For Each searchCell In myRange
If searchCell = storeId Then
cellLocation = searchCell.Address
MsgBox "cell is " & cellLocation
End If
Next searchCell