Hello --
How do I add the text field(s) from the access form to the bottom of the list (1st row without data in it) for the 4 columns in the excel file if it isn't present on the lookup? I know it goes under the spot "ELSE ... 'did not find the value " but I don't know what the coding is, please assist.
Thanks in advance...
How do I add the text field(s) from the access form to the bottom of the list (1st row without data in it) for the 4 columns in the excel file if it isn't present on the lookup? I know it goes under the spot "ELSE ... 'did not find the value " but I don't know what the coding is, please assist.
Code:
Private Sub cmdReplace_Number_Click()
Tech_DB_Changed = "Updated!"
Dim xl As Object, rFound As Object
Set xl = CreateObject("Excel.Application")
With xl.Workbooks.Open(FileName:= _
"\\MyShare\App_Data\Tech_Test.xls")
With .Sheets(1)
'look in sheet 1 column A
Set rFound = .Columns(1).Find( _
What:=[Tech_Number], _
After:=.Range("A1"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not rFound Is Nothing Then
'found the value
.Cells(rFound.Row, "D").Value = [New_Number]
Else
'did not find the value
End If
End With
xl.DisplayAlerts = False
.Save
.Close
xl.DisplayAlerts = True
End With
Set rFound = Nothing
Set xl = Nothing
End Sub
Thanks in advance...