Solved

Inserting SQL Stored Procedure Output into Excel spreadsheet range

Posted on 2014-09-12
5
214 Views
Last Modified: 2014-09-12
I have created an Excel report the obtains selected information from a SQL stored procedures based on parameters sent from cell values in the spreadsheet.


I have a section that will report the list of values from the stored procedure and then sum the values at the bottom of the section.  The problem I am having is placing the output into the section and expand or shrink the area depending on the stored procedure output.  One time the list can be 10 records another maybe 5.

How can I achieve this?

Thanks

glen
0
Comment
Question by:GPSPOW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40320346
Maybe I'm missing something, but if you set up an connection to a SQLServer db with either a query or stored procedure, by default the results should be populating an Excel Table.  As such, the table size is dynamic, but you can also add a totals row that will always be at the bottom of the data table.

Either right-click on the table, then select "Table" and then "Totals Row", OR, click the Table Tools context menu tab, then select "Total Row" from the ribbon.  
Excel Table Totals Row optionYou can define the type of total summary also (ex., sum, average, count).

If there's more to this, please provide more information so we can help resolve.

Regards,
-Glenn
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 40320348
How can I achieve this?
Have you considered posting the relevant code here?
0
 

Author Comment

by:GPSPOW
ID: 40320381
I am trying to copy the results from the table into a range on a form in excel.


Thanks

Glen
0
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40320386
If you're copying it via VBA, then it shouldn't be hard to note the size (row count) of the data to be copied and then adjust the size and position on the destination sheet.  As noted by Anthony, sample code might be helpful.

-Glenn
0
 

Author Closing Comment

by:GPSPOW
ID: 40320402
your solution was what I figured out.  I am in the process of creating the macro to resize the ranges based on the table rows.

thanks

Glen
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

734 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