Hi
I have a form that users fill out and then ping the data into a database. This form can be updated so I'm trying to write a macro that finds the original record in the database then replaces it with the new record.
This is what I've got so far but when it gets to the end of the code I get 'Run time error 1004, Application-defined or object-defined error'.
The record I'm testing this on definitely exists in the database so I know that's not the issue but that's about as far as I get! I will have to build in something for if the record doesn't exist but just trying to get this part sorted first.
Set wb1 = ThisWorkbook 'Data
Set wb2 = Workbooks.Open(FileName:="G:\Exec Reporting\Key Reports\BuildIT\BuildITQuoteFollowUp.xlsm") 'Database
Set src = wb1.Sheets("Form")
Set tgt = wb2.Sheets("Data")
Dim matchRow As Long
Dim findMe As String
' specify what we're searching for
findMe = src.Range("QuoteNo")
' find our search string in column A
Set Match = tgt.Range("A:A").Find(What:=findMe, After:=tgt.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
' figure out what row our search string is on
matchRow = Match.Row
'update data into matched row
tgt.Range(matchRow, 56) = wb1.Sheets("Ref").Range("Data")
Can anyone see where I'm going wrong?
Thanks
Jo
Bookmarks