T
trevorC via AccessMonster.com
Hi,
I need to search for a serial number (Cell Value) in an excel sheet using
access. I have to check several thousand numbers in the excel sheet and
compare them to my access table data and then to update the excel sheet with
a field showing true or false depending on the status of the table entry.
i can do most of this but seem to be having trouble getting the 'find' to
work from access. Any help is greatly appreciated.
Cells.Find(What:="3030265511", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
the above What:="3030265511" is to be repalced with a form reference to loop
through all records
this number IS in the excel sheet but the message i get is 'Object variable
or with block variable not set'
below is my sample code, cut down to it's minimum.
Dim Excel_Application As Excel.Application
Dim Excel_Workbook As Excel.Workbook
Dim Current_Worksheet As Excel.Worksheet
Dim gg
gg = "C:\AAA\update.xls"
Set Excel_Workbook = GetObject(gg)
Set Excel_Application = Excel_Workbook.Parent
Excel_Application.WindowState = xlMinimized
Excel_Application.Visible = True
Excel_Workbook.Windows(1).Visible = True
Current_Worksheet.Cells.Find(What:="3030265511", After:=ActiveCell, LookIn:
=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Excel_Workbook.Save
Excel_Application.Quit
regards Trevor
I need to search for a serial number (Cell Value) in an excel sheet using
access. I have to check several thousand numbers in the excel sheet and
compare them to my access table data and then to update the excel sheet with
a field showing true or false depending on the status of the table entry.
i can do most of this but seem to be having trouble getting the 'find' to
work from access. Any help is greatly appreciated.
Cells.Find(What:="3030265511", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
the above What:="3030265511" is to be repalced with a form reference to loop
through all records
this number IS in the excel sheet but the message i get is 'Object variable
or with block variable not set'
below is my sample code, cut down to it's minimum.
Dim Excel_Application As Excel.Application
Dim Excel_Workbook As Excel.Workbook
Dim Current_Worksheet As Excel.Worksheet
Dim gg
gg = "C:\AAA\update.xls"
Set Excel_Workbook = GetObject(gg)
Set Excel_Application = Excel_Workbook.Parent
Excel_Application.WindowState = xlMinimized
Excel_Application.Visible = True
Excel_Workbook.Windows(1).Visible = True
Current_Worksheet.Cells.Find(What:="3030265511", After:=ActiveCell, LookIn:
=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Excel_Workbook.Save
Excel_Application.Quit
regards Trevor