Solved

Macro is throwing an error

Posted on 2014-09-10
2
196 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Conditional Statements 11 39
Dynamic control of Items in an Excel multiListBox 7 29
locking multiple column ranges 10 25
VBA Fill Blanks with text from another cell 6 21
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

810 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