excell vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

TrustPilot

starstarstarstarstar Excellent

  • Home
  • Courses
  • Promotions
  • Schedule
  • Formats
  • Our Clients

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excell VBA

Excell VBA

resolvedResolved · Medium Priority · Version 2003

Louise has attended:
Excel VBA Intro Intermediate course

Excell VBA

Is there simple code to link to Access from an Excell module?

RE: Excell VBA

Hi Louise,

Thank you for your question.

The code below should allow you to import data from an access table into excel.

Dim strExcelFile As String
Dim strWorksheet As String
Dim strDB As String
Dim strTable As String
Dim objDB As Database

strExcelFile = "E:\CSC\LDMS\LDMSDatabaseApp\LDMS_Spec.xls"
strWorksheet = "WorkSheet1"
strDB = "E:\CSC\LDMS\LDMSDatabaseApp\LDMS_IFF_APP.mdb"
strTable = "Test"

Set objDB = OpenDatabase(strDB)

'If excel file already exists, you can delete it here
If Dir(strExcelFile) <> "" Then Kill strExcelFile

objDB.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet & "] FROM " & "[" & strTable & "]"
objDB.Close
Set objDB = Nothing

I hope this helps.

Regards

Simon

Tue 23 Jun 2009: Automatically marked as resolved.


 

Excel tip:

Conditional formatting for cells that return text , not picked up by Go to command

If you have tried to format all cells containing text even those that display text as a result of a formula you may have had difficulty. As Go to command with constant selected does not pick up formulas that result in text.

Then try this. Select the range the formula cells appear in on your sheet. Format, select Conditional Formatting menu. In the dialog box under Condition 1, select "Formula Is" from drop down. Next to it in the Formula Box, enter the formula =Istext(A1. Click Format button , choose desired formatting settings and click OK. To go ahead and apply the conditional formatting click OK to accept

View all Excel hints and tips


Server loaded in 0.07 secs.