Solved

Macro is throwing an error

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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