Application-defined Or Object-defined Error Querytables
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the application defined or object defined error excel workings and policies of this site About Us Learn more about Stack
Application Defined Or Object Defined Error Access
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Application Defined Or Object Defined Error 32809
Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join
Application Defined Or Object Defined Error In Macro
them; it only takes a minute: Sign up Application Defined or Object Defined Error on QueryTable up vote 1 down vote favorite I'm trying to take data from a table in SQL and export it to a worksheet using VBA. I have been unable to figure out how to do this without creating a new data connection each time. application defined or object defined error in vba Here is what I have been doing as of now: I am putting the SQL query into a cell and giving the variables names like '#ID' and "Date". In the macro, I am replacing the data within those variables with the actual information. That has not given me any problems thus far as the query runs without issue when using SQL. To export the data from SQL to my worksheet, I am using code that works in other workbooks; however when I run it in this workbook, I am getting the error "Application Defined or Object Defined Error". Here is the full macro: Sub CurrentBreakout() Dim SQLString As String Dim ID As String Dim Date As String Dim year As String Dim daycount As String SQLString = Range("CurrentBreakout") 'This is the range where the query is stored ID = Range("ID") Date = Range("CurrMonth") year = Range("CurrYear") daycount = Range("CurrDayCount") SQLString = Replace(SQLString, "#ID", ID) SQLString = Replace(SQLString, "#Date", Date) SQLString = Replace(SQLString, "#CurrDayCount", daycount) SQLString = Replace(SQLString, "#CurrYear", year) With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _ "ODBC;DSN=____________;UID=________;Trusted_Connection=Yes;APP=Microsoft Office 2010;
here for a quick overview of the site Help Center Detailed application defined or object defined error vba 1004 answers to any questions you might have Meta Discuss the application defined or object defined error vba formula workings and policies of this site About Us Learn more about Stack Overflow the company application defined or object defined error vba range Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join http://stackoverflow.com/questions/35186925/application-defined-or-object-defined-error-on-querytable the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBA Runtime Error 1004 “Application-defined or Object-defined error” up vote 0 down vote favorite I'm running multiple worksheets to populate data http://stackoverflow.com/questions/36488630/vba-runtime-error-1004-application-defined-or-object-defined-error for my meetings. Every time I try to run I get a memory error and then the '1004' error. I am a beginner at coding so please give detail. Any suggestions? Sub PullData() Application.ScreenUpdating = False Application.EnableEvents = False Sheets("Production").Select Dim StartYear As String Dim StartMonth As String Dim StartDay As String Dim EndYear As String Dim EndMonth As String Dim EndDay As String Dim NextDay As String Dim StartHour As String Dim EndHour As String StartYear = Year(Range("b2").Value) StartMonth = Month(Range("b2").Value) StartDay = Day(Range("b2").Value) EndYear = Year(Range("b2").Value) EndMonth = Month(Range("b2").Value) EndDay = Day(Range("b2").Value) NextDay = EndDay + 1 StartHour = Hour(Range("b3").Value) EndHour = Hour(Range("b3").Value) Sheets("PPA").Select Cells.Select Selection.ClearContents With ActiveSheet.QueryTables.Add(Connection:="URL;https://fclmportal.amazon.com/ppa/inspect/node?nodeType=FC&warehouseId=ONT8&startDateDay=" & StartYear & "%2F" & StartMonth & "%2F" & StartDay & "&startDateWeek=" & StartYear & "%2F" & StartMonth & "%2F" & StartDay & "&startDateMonth=" & StartYear & "%2F" & StartMonth & "%2F" & StartDay & "&maxIntradayDays=1&spanType=Intraday&startDateIntrada
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers https://social.msdn.microsoft.com/Forums/en-US/3339ded6-726b-42b0-8fba-1421c7a05eb4/runtime-error-1004-applicationdefined-or-objectdefined-error-editing-a-data-checking-workbook?forum=isvvba Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Asked by: Run-Time error '1004': Application-defined or object-defined error (Editing a data checking workbook I did not create) Microsoft ISV Community Center > Visual Basic for Applications (VBA) defined or Question 0 Sign in to vote PLEASE HELP ME, I have a deadline I need to meet tomorrow and in order to complete my work I need to use this 'data checking' sheet that I am not familiar with (please note I am a total newby at VBA so please be kind). I made the changes I needed to and then when I hit the defined or object Macro button I recieved "Run-Time error '1004': Application-defined or object-defined error". When I select Debug it takes me to VBA and this is what I can see: Private Sub btnRefresh_Click() Application.ScreenUpdating = False Sheets("AM").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("PM").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("Peaks").Select End Sub Private Sub btnRefresh_Links2_Click() On Error Resume Next Range("A1").Select ActiveWorkbook.UpdateLink Name:= _ "P:\PSG NA Common Folder\OTR 2011 - 2012\2011_12 Worksheet.xls", Type:= _ xlExcelLinks End Sub Private Sub btnRefresh2_Click() Application.ScreenUpdating = False Sheets("AM Contra").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("PM Contra").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("Off Peak").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("Weekend").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("DTP").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("Other Periods").Select End Sub The line "Selection.QueryTable.Refresh BackgroundQuery:=False" is highlighted in yellow, which makes sense because that is the worksheet that I made changes to..... but now how do I fix the problem? I have NO IDEA how to use VBA - can anyone help?!?!?!?! Wednesday, February 13, 2013 6:34 AM Reply | Quote All replies 1 Sign in to vote This seems that the query is depending on external data source.I assume you did not change/remove anything there. Change the Activecell