Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Form creates new workbook and pulls data


Is my logic correct? I have a macro running in a workbook that asks the
user for the account number. On Click, I want the macro to create and
save a new workbook with the account number as file name, then excecute
a query to pull data from a database.

The macro ran fine when taking the account number and pasting it on a
new sheet in the same workbook. Its failing now that I am trying to
get the data onto a new xls. Am I trying something not possible?


--
luke99s
------------------------------------------------------------------------
luke99s's Profile: http://www.excelforum.com/member.php...o&userid=28016
View this thread: http://www.excelforum.com/showthread...hreadid=475224

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Form creates new workbook and pulls data

Your logic is OK - there are ways to do this. Would need to see the code to
see why it may not be working. Also, how is it failing? - what happens?
--
- K Dales


"luke99s" wrote:


Is my logic correct? I have a macro running in a workbook that asks the
user for the account number. On Click, I want the macro to create and
save a new workbook with the account number as file name, then excecute
a query to pull data from a database.

The macro ran fine when taking the account number and pasting it on a
new sheet in the same workbook. Its failing now that I am trying to
get the data onto a new xls. Am I trying something not possible?


--
luke99s
------------------------------------------------------------------------
luke99s's Profile: http://www.excelforum.com/member.php...o&userid=28016
View this thread: http://www.excelforum.com/showthread...hreadid=475224


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Form creates new workbook and pulls data


Thinking there may be a problem with moving data between workbooks, I've
tried to see if I could move it between worksheets. The operation still
fails, I now get an error " The desination range is not on the same
worksheet that the query table is being created on "

In a nutshell, workbook when opened has only a sheet with a form on it.
User enters client account number and hits enter. On click, the
account number is pulled and inserted into the query below. Query
connects to our database to bring data into new sheet with name the
same as the account number. When I do this manually everything is
peachy... its the macro that is failing! please help and thanks in
advance!

I've pasted a snippet of where my problem seems to be...


<code
A = custnum.Value
ActiveWorkbook.Worksheets.Add(After:=Worksheets(Wo rksheets.Count)).Name
= A
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _

"URL;http://intranet/POOL_Digest/Digest/MainPage.aspx?ResourceID=1&ResourceName=CustomerSa lesByProductsInProductLineByYear&SRN=/All/Digest/Customer/Sales/CustomerSalesByProductsInProductLineByYear\Custome r{10"
& A & "}&AuxRI=All!" & A & "" _
, Destination:=Range("A1"))
..Name = "Customer{10" & A & "}&AuxRI=All!" & A & ""
..FieldNames = True
..RowNumbers = False
..FillAdjacentFormulas = False
..PreserveFormatting = True
..RefreshOnFileOpen = False
..BackgroundQuery = True
..RefreshStyle = xlInsertDeleteCells
..SavePassword = False
..SaveData = True
..AdjustColumnWidth = True
..RefreshPeriod = 0
..WebSelectionType = xlSpecifiedTables
..WebFormatting = xlWebFormattingNone
..WebTables = "1"
..WebPreFormattedTextToColumns = True
..WebConsecutiveDelimitersAsOne = True
..WebSingleBlockTextImport = False
..WebDisableDateRecognition = False
..WebDisableRedirections = False
..Refresh BackgroundQuery:=False
End With

</code


--
luke99s
------------------------------------------------------------------------
luke99s's Profile: http://www.excelforum.com/member.php...o&userid=28016
View this thread: http://www.excelforum.com/showthread...hreadid=475224

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
workbook creates a backup evertime I save it. how to remove? Roger Excel Worksheet Functions 0 September 7th 07 09:56 PM
Combo Box Pulls data jrascal Excel Discussion (Misc queries) 0 July 20th 07 06:38 PM
How under the insertion pulls in the excel form tabulates the fram lijinchao New Users to Excel 0 November 16th 05 10:38 AM
Excel 2k3: Workbook on network drive, when save creates new file AVCCTech Excel Discussion (Misc queries) 1 July 7th 05 08:05 PM
workbook creates desktop shortcut...HELP daredevil Excel Programming 0 November 13th 03 01:53 AM


All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"