Solved

Macro is throwing an error

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
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.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

863 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

24 Experts available now in Live!

Get 1:1 Help Now