Solved

Macro is throwing an error

Posted on 2014-09-10
2
183 Views
Last Modified: 2014-09-16
On Aug 6th, 2014, ProdOps helped me with an awesome macro. The title of the question was "How to combine two tables into one?". ProdOps helped me and it worked! However, I want to move the three tabs (including the macro) to another spreadsheet. So I right clicked on the three worksheets and moved them to the spreadsheet i want them to ultimately reside on. This other spreadsheet has additional information i want in one place. When I click the button to create the table, i get an error. Attached is the error i'm getting. How do I fix this?
MacroError.png
0
Comment
Question by:brasiman
2 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 40315981
Check the original working excel file. There are probably references set (after you open vba with alt+f11). Check them, and set the same references in the new excel file.
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 40316400
Change Jerry's code to this:

Function Create_accdb_AccessDb()

    Dim newDb As String
    On Error GoTo errHandler

    newDb = Range("AccessDb").Value

TryAgain:
    CreateObject("ADOX.Catalog").Create "Provider='Microsoft.ACE.OLEDB.12.0';" & _
               "Data Source='" & newDb & "'"

finished:
    Debug.Print newDb & " created."
    Exit Function

errHandler:
    ' If the Access Db name already exists the Create File will fail.
    ' Delete the current Access Db and resume to "TryAgain:" to
    ' create a blank database after the old one has been deleted.
    If Err.Number = -2147217897 Then
        Kill newDb
        Resume TryAgain
    Else
        MsgBox "ErrNum= " & Err.Number & ", ErrDesc = " & Err.Description & _
        ", 'MOD_RefreshData', 'Create_accdb_AccessDb", vbCritical, "Application Error"
        Resume finished
    End If

End Function

Open in new window


and you won't need a reference.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now