Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Excel Spreadsheet 1

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
IE
I need to read access table and then look for this value in an excel spreadsheet. If i find it i then need to update the 3rd column on the same row of the spreadsheet. I'm new to this being from a unix background. Is it possible to do from access VB? If so can i get some pointers or alternatives.
 
Option Compare Database
Option Explicit
Sub OpenExcel()

Dim objExcelApp As New Excel.Application
Dim objExcel As Object
Dim sht as excel.worksheet
'create Excel
Set objExcelApp = New Excel.Application
'open file
Set objExcel = objExcelApp.Workbooks.Open("D:\booknew.xls")
objExcelApp.Visible = True

set sht = objexcel.sheets("Sheetname")

'Get your number from Access - store as "testNum"

with objExcel.sht
set fCell = .columns("A").find(testNum,lookin:=xlvalues, lookat:=xlwhole)
if not fCell is nothing then
'number found
fCell.offset(0,3).value = "Update This Cell"
else
msgbox "Number " & testNum" & " not found"
end if
end with

Set objExcel = Nothing 'clears memory

End Sub

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
Get the best answers to your questions - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top