Excel 2010 :: Assigning Name To Range Received By ODBC Query

Apr 29, 2014

I have been working on some ODBC queries in Excel 2010.

First, I recorded them using Excel's Record Macro function, to get an idea of what sort of source data I would need. Then, I rewrote them into something a little more intelligible.

Pulling out all the sensitive info, I want to know how to add the .ListObject.DisplayName property back onto the results of the query. I tried doing it intuitively, but it didn't work. It was in there when I recorded the macro, but I can't seem to figure out where to put it back into the re-written code. Other parts of the code depend on the results of the query being a 'named field'.

[Code] .....

Also, where would I find out what all that stuff in Cnnect means? DBA, APA, EXC, FEN, etc are all just assignments, and I might like to change some to make this run a bit quicker, if I knew what they meant.

View 6 Replies


ADVERTISEMENT

Excel 2007 :: ODBC Connection Query Shows No Result

Mar 25, 2013

Why this sql query doesn't return values? My excel version is 2007.

Code:
if object_id( 'TEMPDB..#TMPDOC') is not null
begin
drop table #TMPDOC
end

create table #TMPDOC (Code varchar(5) NOT NULL)

[Code] ...........

View 6 Replies View Related

Excel 2010 :: ODBC Connection String With Multiple Variable (WHERE) Requirements

Dec 29, 2013

With VBA in Excel 2010 I am connecting to a SQL server by using ODBC.

This is a two part process:

Part one:I have created a connection string that gets me the following data: A, B, C, D, E from sheet tpoPurchOrder Where B is equal to "1" And Where C is equal to a changing field under Sheets("Macros").Range("B2")

Here is part one

Code:

Sub Part1()
Sheets("Open PO by Vendor").Select
Sheets("Open PO by Vendor").Cells.Clear
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DSN=Connection;Description=Description;UID=USER;PWD=PASSWORD;APP=Microsoft Office 2010;WSID=Workstation;DATABASE=Database" _
, Destination:=Range("$A$1")).QueryTable

[code]...

Part one works perfectly.

Part two is where I have problems.Part two is a little different because I have the same connection, but what changes is the table that I am looking at "tpoPOLine" instead of "tpoPurchOrder" and the where is now going to have a variable number of commands.

I want part two to be depend on part one. Under part one I want the result from column E to be a where statement in part two.

As follows:

In particular: *E3 from Part 1*, etc.

Code:
"SELECT tpoPOLine.Status, tpoPOLine.POKey, tpoPOLine.ItemKey, tpoPOLine.POLineNo, tpoPOLine.UnitCost, tpoPOLine.ExtAmt" & Chr(13) & "" & Chr(10) & "FROM mas500_DII_app.dbo.tpoPOLine tpoPOLine" & Chr(13) & "" & Chr(10) & "WHERE (tpoPOLine.POKey=*E2 from Part 1*) OR (" _
, _
"tpoPOLine.POKey=*E3 from Part 1* ) OR (tpoPOLine.POKey=*E4 from Part 1*)" & Chr(13) & "" & Chr(10) & "ORDER BY tpoPOLine.POKey" _
)

Now my problem is that sometimes the E column from part one ends up being 1 row, sometimes it ends up being 50 rows. I would like the code to change accordingly.

1. Pull everything from the SQL server filter once in excel. This is not as efficient as the database has ~300,000 rows in the tpoPOline table and would take a lot longer then needed.

2. Create a nested if table and

Change

Code:
WHERE (tpoPOLine.POKey=*E2 from Part 1*) OR (tpoPOLine.POKey=*E3 from Part 1* ) OR (tpoPOLine.POKey=*E4 from Part 1*)"

to the value of that nested if table

The nested if table would be something like =if(isblank(E2),"E1",if(isblank(E3)... etc for ~50 rows. I know the syntax is incorrect but you get my point.

3. Rerun the query for each value in column E. That would require the connection to happen ~50 times which would not be that great, as well as I would have to copy and paste the data after each run as the tables cannot overlap.

What I am looking for is a way to run this only once, on one sheet, without writing a nested if table with 50 if's.

View 5 Replies View Related

ODBC Query Returns To Textbox?

Oct 20, 2011

I would like an ODBC query to return the reults to a textbox on my userform.

View 1 Replies View Related

VBA Set ODBC Connection String For Query

Jul 25, 2008

My workbook has 9 queries, all needing the same string. I would like to have a msgbox pop up, let them enter the directory name, and have that change all the odbc conneciton strings automatically. Can anyone point me in the right direction?

The message box would be a nice touch, but is not necessary, I can change it in the VBA editor if needed.

Currently, they connect using a Visual FoxPro ODBC driver. We setup the connection when we made the queries. Now that they are in on the worksheets, I want to be able to edit them with VBA instead of using the script editor (which is very slow).

View 9 Replies View Related

Excel 2010 :: Web Query Using Changing Filename

Mar 6, 2014

I'm using excel 2010, looking to import a .xls file to a tab from a web query. Herein lies the problem: the .xls file is named based on the current date. So for instance, xLfile03.05.14.xls. Which changes the next day to xLfile03.06.14.xls. This is not a local file but one on microsoft sharepoint. It's ONLY available through sharepoint.

View 1 Replies View Related

Excel 2010 :: Pivot Table Filter Query

Feb 21, 2012

I have created a pivot table in Excel 2010 that lists amounts used of particular items each month. Inside the pivot table value field settings i have changed the show values as field so that it displays the difference in usage from this month to last.

However if i now select a top 10 filter it only filters by the total number used as opposed to the difference in usage from one month to the next (which is the values displayed).

Is there a way that i can filter by top 10 by the actual values displayed in the pivot chart and not just the underlying data that creates it?

View 4 Replies View Related

Excel 2010 :: Workbook With Two Sheets / Query Parameters

Mar 6, 2012

I have a workbook that contains two sheets with two separate queries. On the first sheet I have two cells designated to accept the values for the parameters. The first sheet accepts the values and populates the table correctly. The second sheet doesn't seem to accept the values and just returns blank rows.

View 9 Replies View Related

Assigning Cell Value In Web Query Connection?

Jun 15, 2014

I have a macro which retrieves data from web.It works fine.I just don't know how to assign a cell value in web address.i have attached the code here. i just want to assign activesheet.(range"c2").value for "q?s".

View 1 Replies View Related

Pivot Refresh After ODBC Query Complete Refresh

Jan 4, 2008

I have a query with ODBC connection to a SQL database. This query's parameter is linked to a cell. The resultant data is the source for a pivot table. I want to refresh the pivot table, when the query is run. I've tried using the cell that triggers the query....but the problem is that the query takes about 10 seconds to run. By the time the query returns new data....the pivot has already refreshed. I need it to refresh AFTER the query is complete.

I tried adding a cell that sums up the data from the query...thinking when THAT changes (due to updated data), to trigger the pivot refresh. Problem is that I don't know the trigger for when the sum cell changes (ie....formula change, not typed in.)

View 9 Replies View Related

Excel 2010 :: ADO Recordset Query Quandary Locating Duplicates

Mar 13, 2013

I am having trouble setting up a query for a recordset that will list duplicates for an automated process to clean up. I am using Excel 2010 with Microsoft ActiveX Data Objects Recordset 6.0 Library and Microsoft ActiveX Data Objects 6.1 Library as references.

So far, I have chopped the query down to it's most basic elements and reassembled until it broke. Necessary pieces work well, but when I combine them, I get nowhere.

Here is the working simple query to retrieve a single row:

Code:
dupeSQL = "SELECT PSID FROM [Obstructed$] "

Here is the working single query to retrieve a count:

Code:
dupeSQL = "SELECT COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] "

When combined, I cannot figure out why it won't work:

Code:
dupeSQL = "SELECT [PSID], COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] "

Here is what I am trying to get to:

Code:
dupeSQL = "SELECT [PSID], COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] " _
& "WHERE COUNT(PSID) > 1 " _
& "GROUP BY PSID"

I can even work without the GROUP BY. I have also played with the HAVING clause to try and accommodate the [PSID] field, but have gotten nowhere.

View 1 Replies View Related

Excel 2010 :: SQL Query DB - Error - Could Not Find Installable ISAM

Jan 19, 2014

I am trying to perform an SQL query on an Excel worksheet, as per one of the examples in Michael Alexander's book "Excel and Access Integration: With Microsoft Office 2007" and I am encountering an error message.

Could not find installable ISAM

To clear I am trying to pull data from one Excel workbook to another using SQL.

I am using Excel Excel 2010 64 bit.

This is the code I am running.

Code:
Sub GetData_From_Excel_Sheet()
Dim MyConnect As String
Dim MyRecordset As ADODB.Recordset

[Code]....

I have some across a few times that relates specifically to Excel 2010 64 bit is that I need to install the following driver

Microsoft Access Database Engine 2010 Redistributable

However I already have this driver (I installed when I was trying to figure out how to write from Excel to Access).

Why am I receiving this message. It occurs when my code reaches this line:

Code:
MyRecordset.Open MySQL, MyConnect, adOpenStatic, adLockReadOnly

View 9 Replies View Related

Assigning Excel Range To Variable And Then Paste It In Outlook Message Box

Jul 19, 2012

I am writing a code wherein I want to assign specific excel range to a declared variable and then paste this excel in outlook message ody but I am finding difficulty in assigning that range to variable " brng"

I think code is right and issue is there in excel setting.

Code:
Sub mailer()
'
'
'
Dim Ash As Worksheet
Dim brng As Range
Dim OutApp As Object
Dim OutMail As Object
'Windows("Copy of FF RPL REPORT_JULY").Activate

[Code] .......

View 1 Replies View Related

Excel 2010 :: Access Data Connection Query - Missing Data All Of Sudden

Oct 19, 2012

I created a slick little excel sheet with the data coming in automatically via Access query. It has been working fine for months. Now all of the sudden there are a bunch of cells with missing data. The weird part is it's not as if whole columns are missing data, more like 90% missing. When I go to Access and run the query all cells are populated as the should be. There have been no changes to the query at all during this time.

btw...I am running Office 2010

View 2 Replies View Related

Excel 2010 :: How To Get Power-query And Power-pivot

Jun 28, 2014

How to get Power-query and Power-pivot for Excel 2010?

View 9 Replies View Related

Pass Parameter From Excel Through MS Query To MS Access Query

Nov 26, 2012

I have an MS Access query that contains a parameter. The parameter is a date field, and I have configured that in the Access query. If I run the query within the MS Access user interface, it prompts me for the paramater value as expected, and runs just fine. However, I want to connect to this query from within Excel as a data source.

I have created a connection to the Access file using ODBC from within Excel. In the MS Query window, I am merely selecting all of the fields resident in the MS Access query, and returning all values. In other words, there is no selection criteria in the MS Query. I have done this many times with Access queries that DO NOT contain a parameter, and everything works fine. However, in this instance, I need to pass a parameter through to MS Access in order for the query to run. At the moment, I get the "Too Few Paramaters...1 expected" error message. This makes sense, because I haven't figured out how to pass the paramater to MS Access.

Is there a way to structure this that does not involve VB code? If so, I'd love to know how. I have tried creating parameters in MS-Query with the same name, but although I get the prompt it doesn't connect with the Access query as the source for the parameter value.

If the solution requires using code, I'm good with VB Code in Excel...is there VB for Excel code that could make this happen?

Failing that, I guess there must be (I've seen a few in my search thus far) Access VB Code that can make this work. I'm very rusty using VB with Access, so this is my least favored solution. However, if this is the only option, keep in mind that I need to pass the paramater ultimately from a user who will initiate the process using Excel.

View 3 Replies View Related

Excel 2010 :: Return Min Date In Range Where Adjacent Range Is Blank?

Feb 7, 2014

I am working in excel 2010. I have a tracking document that lists free tickets and their expiry dates. In the adjacent columns we track redemption details of these free tickets. What I want to do is return the oldest expiration date from A only if the ticket has not been used (i.e. B is empty). This will allow me to see the date the upcoming tickets about to expire so we can make sure they are used.

A________________B
Expiry Date________Redeemed by
15/08/2014
15/02/2014
15/08/2014________John
15/02/2010________Marc
15/02/2011________Bob

View 4 Replies View Related

Excel 2010 :: Row Number Range From Date Range?

Aug 5, 2013

I have a column of dates in Col H with associated values in Col I. I need to specify a date range in Cell I1 and I2 such that the row number for the first encounter of the first date is placed in Cell I3 and the last encounter of the end date is placed in Cell I4. For example, with this data when I specificy 4/2/13 and 4/3/13, I would like to get a 19 in Cell I3 and a 53 in Cell I4.

Matty supplied the formula in Col K for each of these cells. They worked well in the application that I supplied earlier (different locations for these variables), but my real application is as shown here, and these two formula give the incorrect results shown. Both of these formula are arrays.

Excel 2010HIJK14/2/201324/3/2013310=MATCH(I1,INT(H10:H5000),0)+1444=MATCH(2,1/(INT(H11:H5000)=I2),1)+1536789X10 114/1/13 1:366.97124/1/13 2:04134/1/13 2:04144/1/13 4:563.95154/1/13 4:573.27164/1/13 5:165.55174/1/13 5:172.35184/1/13 10:30194/2/13 14:00204/2/13 14:59214/2/13 15:01224/2/13 17:192.81234/2/13 17:191.59244/2/13 17:252.14254/2/13 17:262.05264/2/13 21:07274/2/13 21:07284/2/13 21:11294/2/13 21:11304/3/13 1:38314/3/13 1:38324/3/13 2:10334/3/13 2:10344/3/13 4:24354/3/13 5:152.84364/3/13 5:154.11374/3/13 5:173.45384/3/13 5:173.24394/3/13 9:35404/3/13 9:35414/3/13 9:59424/3/13 10:01434/3/13 13:36444/3/13 13:37454/3/13 13:41464/3/13 13:42474/3/13 17:124.03484/3/13 17:133.62494/3/13 17:15504/3/13 17:15514/3/13 21:12524/3/13 21:13534/3/13 22:214.41544/4/13 1:52554/4/13 1:52564/4/13 1:53574/4/13 1:53Ppk Raw Data (2)

View 2 Replies View Related

Excel 2010 :: Cannot Delete A Range Name

Nov 28, 2013

Workbook contains a number of named ranges where the name is no longer used. I wish to remove the name assigned but not the actual range of referenced cells. When using Name Manager to try and delete the name the Delete button is greyed out and not available. Workbook is being heavily modified from its original form used by another. Is this possibly from a protected area from prior user? However, I have not had a problem creating new worksheets, cell ranges, etc. Also, even for new ranges I create I am not able to delete the name as the Delete button is greyed. What is going on and how can I delete just the unused range names? Version is Excel 2010.

View 3 Replies View Related

Excel 2010 :: Pivot Dynamic Name Range?

Jan 27, 2013

I am trying to insert a Pivot table with dynamic Name Ranges. It needs to start from Cell B1 as Column A has hidden formulas in them. I created an Dynamic Name range and tried to insert a pivot table. Excel then throws out a error stating "Data source reference is not valid". I tried re-saving the document but still no luck.

View 1 Replies View Related

Excel 2010 :: VBA - How To Convert A Range To A Table

Jan 27, 2014

I am relatively new to VBA and am trying to convert a range of data to a table in the same sheet. I receive the following message when I try to run the code as shown below:

"The worksheet for the table data must be the same sheet as the table being created." The code stops on the third line of the code.

Sheets("Data Forwards").Select
ActiveSheet.Range("$A$1:$U$1000").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$U$1000"), , xlYes).Name = _
"Table1"
ActiveSheet.Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium2"

I can see that the range is highlighted in the sheet before the code breaks.

View 3 Replies View Related

Excel 2010 :: VBA Input Box For Range Selection

Sep 6, 2012

Excel 2010. I have a macro, stored in a workbook.

The macro is: collecting data from another opened workbook,processing the data,saving the processed data in yet another workbook.

The workbooks' names it is operating on are hardcoded in the macro. I'm trying to make it more flexible, that is to allow user to specify both source and target workbooks along with the data columns.

The workflow follows:

User opens both source and target workbooks,User opens the workbook with the macro,User runs the macro (with a button for example),Macro prompts the user to select range in the source workbook,Macro "memorizes" the range and the source workbook's name from user's selection,Macro prompts the user to select range in the target workbook,Macro "memorizes" the range and the target workbook's name from user's selection,Macro processes the data.

I found out that this can be achieved with Application.InputBox("Select cell(s)", Type:=8) method. However there are some issues that I was not able to solve playing with the returned value's methods:

The .InputBox defaults to active workbook. I was able to select another opened workbook only with Ctrl+Tab combination, but it will not work with the end users - they are too poor with these tricks. Is there a better, more intuitive way to allow user selecting a workbook?I was not able to get the workbook's name from the .InputBox returned value property. I was trying with .application.caption and .application.activeworkbook.name - none of these worked. They returned name of the workbook with macro, not the one with selected range. How to get the workbook's name from given cells range?

View 2 Replies View Related

Excel 2010 :: Allowing Edit On Specified Range

Jan 6, 2013

Run on Excel 2010

Sub UseChangePassword() Dim wksOne As Worksheet Set wksOne = Application.ActiveSheet
' Protect the worksheet. wksOne.Protect ' Establish a range that can allow edits ' on the protected worksheet.
wksOne.Protection.AllowEditRanges.Add _ Title:="Classified", _ Range:=Range("A1:A4"),
_ Password:="secret" MsgBox "Cells A1 to A4 can be edited on the protected worksheet."
' Change the password. wksOne.Protection.AllowEditRanges(1).ChangePassword
_ Password:="moresecret" MsgBox "The password for these cells has been changed." End Sub

The red color code is giving error message: Application defined or Object defined error.

View 1 Replies View Related

Excel 2010 :: Autofill Ever Changing Range?

Jan 23, 2013

Excel 2010

I have this code in a macro, the range will change as more data is added. so that I dont have to keep changing the range. How can I have this code autofill from the activecell to the last cell that has data in column M.

Selection.AutoFill Destination:=ActiveCell.Range("A1:A50000")
ActiveCell.Range("A1:A50000").Select

View 7 Replies View Related

Excel 2010 :: How To Pick Last Entry In Range

Mar 19, 2013

I have to report Actual Headcount every month. Since I cannot add the Headcount numbers in the FY Column. What is the best possible forumula I can use to pick the last month's reported numbers into the FY Column.

For example.

I have 13 columns (A - M). Jan - Dec and the 13th column is the FY number.

This month, I am reporting March numbers in Column C

Column D through N (Apr through Dec) are emplty

I need Column N (FY number) to read Column C and enter the value from that cell.

similarly when I report April numbers in Column D next month, I want Column N to read April numbers and ignore the prior months.

I tried using the min/max function but since h/c fluctuate every month I could not use that. I could use an "if" statement and go back every column but that seems to be inefficient way to solving for this. Any thoughts?

BTW, I am using Excel 2010

View 4 Replies View Related

Excel 2010 :: VLookup With Named Range Not Updating?

Oct 5, 2011

There is a formula

=vlookup(a1,Named_Range,2,false)

if I change a value in the range named "Named_Range" this vlookup does not update.

This formula works but does not allow for any updates. Meaning the vlookup returns the original value even after a cell has been changed. "Named_Range" is on a different sheet but in the same workbook.

Auto calculate is on. I have recalculated the cell manually. I have Office 2010

View 1 Replies View Related

Excel 2010 :: Identify Range Of Dates For Given Date?

Jul 26, 2012

I've gotten the desired result in Column B, but this will not work going forward as we add to the table in columns E:G .

I'm looking to search between columns E:F, Identify the date-range where my dates in column A belong, and pull the corresponding rate from column G into column B.

Excel 2010
A
B
C
D

[Code]...

View 8 Replies View Related

Excel 2010 :: Averageifs Formula For A Specified Date Range

Nov 27, 2012

Using Office 2010, I am trying to do a averageifs formula for a specified date range. I can get it working by specifying the date range in the formula itself, however when "pointing" the formula to a specific cell with a date in it, the formula gives me a div/0 error.

Formula that works is:
=AVERAGEIFS('UHP Weld Data'!M:M,'UHP Weld Data'!B:B,"08/29/2012")

What I need is a version of: (currently not working)
=AVERAGEIFS('UHP Weld Data'!M:M,'UHP Weld Data'!B:B,"H1")

The date range will constantly change as I want it to show me the past 30 days only.

View 1 Replies View Related

Excel 2010 :: Dynamic Range Not Working Properly

Jan 8, 2013

Had been using this formula for almost 3 years, recently the formula didn't work properly as the range goes down halfway only instead of to the last data in the column. I'm using Excel 2010 now.

=Sheet1!$A$2:INDEX(Sheet1!$A:$A,COUNTA(Sheet1!$A:$A))

View 2 Replies View Related

Excel 2010 :: Formula For Duplicates Within Date Range

May 31, 2013

How to set up a formula on Excel 2010 using Conditional Formatting.

I want to identify duplicate account #'s within 15 days of the work date. Here is sample of the report.

Account Number
Facility
FC
Payor
Current Balance
Aging Level
Team Member
Work Date

87890
HHSS
1
BCBS OF TX (PPO)
$9,616.94
121+
Steven Johnson
5/20/2013

[Code] .........

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved