read/write from closed file???

ddragas

Board Regular
Joined
Jun 11, 2002
Messages
83
I've got database over 30.000 codes (rows).
When I make formula like "=VLOOKUP(B5;'C:\Documents and Settings\Dejan\Desktop\[Ponude.xls]Šifre'!$A$2:$L$32199;5)" it works, but :help: I need VBA code to make the same thing like formula does.

Something like in access and visual basic.

thank you

Best wishes
 
Thnx Mike for help, but I don't want any formula in worksheet, because user of application is complete beginer in excel, and worksheet needs to be unlocked.
For that reasen I need something like Nimrod sugesed me, but now I need help in that direction.


Here is code that I'm using now:

Application.ScreenUpdating = False

Path = Range("b1")
data = Range("b2")
ime = Range("b3")

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = OpenDatabase(Path & data, False, False, "Excel 8.0")
Set rs = db.OpenRecordset("SELECT * FROM [Šifre$]" & _
"WHERE [Šifra] like 'k9'") ' HERE IT SHOULD FIND THE SAME VALUE LIKE I' WROTE IN RANGE("K9")

'While Not rs.EOF
Range("l9") = rs.Fields(1).Value
rs.MoveNext
'Wend

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

Thnx folks
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
…I don't want any formula in worksheet, because user of application is complete beginer in excel, and worksheet needs to be unlocked
.
See this part of my macro – all formulas are converted to values i.e. the users will not see the formulas:
Code:
For i = 1 To 2 
    rng.Offset(0, i).Formula = rng.Offset(0, i).Value 
    Next
BTW, it does not matter if the source file is protected – the macro will still work. If you want to protect the destination file, then in the destination file, unlock the cells that will house the looked up values (select the cells, then go to the Format menu |Cells |Protection and remove the tick from the locked checkbox, then apply protection).

Regards

Mike
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,341
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top