Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am attempting to open two different queries in the same workbook, as
individual sheets. Whenever I run the code for the second query Excel open a new workbook. Does anyone know how to retrieve the data into the current workbook. The code I am using is a follows. Please bear with me I am very new at using VBA. 'The first query has already ran and opened in Excel. Adding sheets for next query. Sheets.Add Sheets("Sheet1").Select Cells.Select ' Code to Navigate through the Database Setup SendKeys ("{TAB}") SendKeys ("~") On Error GoTo errhandler Workbooks.Open ("C:\Documents and Settings\dminor\Desktop\query\Blanket Order Query.dqy") errhandler: If Err.Number = 1004 Then Application.DisplayAlerts = False Application.EnableEvents = False ActiveWorkbook.Close SaveChanges:=False Application.Quit End If Resume Next End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without knowing your setup, have you tried using
DataGet External Data to create two separate queries on separate worksheets. These can update automatically upon Workbook_Open or whenever you Refresh them. vb code is not needed to set these up. "Dave M." wrote: I am attempting to open two different queries in the same workbook, as individual sheets. Whenever I run the code for the second query Excel open a new workbook. Does anyone know how to retrieve the data into the current workbook. The code I am using is a follows. Please bear with me I am very new at using VBA. 'The first query has already ran and opened in Excel. Adding sheets for next query. Sheets.Add Sheets("Sheet1").Select Cells.Select ' Code to Navigate through the Database Setup SendKeys ("{TAB}") SendKeys ("~") On Error GoTo errhandler Workbooks.Open ("C:\Documents and Settings\dminor\Desktop\query\Blanket Order Query.dqy") errhandler: If Err.Number = 1004 Then Application.DisplayAlerts = False Application.EnableEvents = False ActiveWorkbook.Close SaveChanges:=False Application.Quit End If Resume Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Running a macro in a open as read-o Workbook | Excel Programming | |||
Running a macro in a open as read-o Workbook | Excel Programming | |||
Running a macro in a open as read-o Workbook | Excel Programming | |||
Application Error when running Macro on Workbook open | Excel Programming | |||
Application Error when running Macro on Workbook open | Excel Programming |