Web Queries In Modules

Aug 8, 2006

I'm trying to produce a spreadsheet that pulls infomation from different web pages throughout the day. It needs to pull quite a large amount of information from different web pages hence I wanted to produce a subroutine which could be called with different variables for each web page, i.e. url, field, destination, etc.

To actually produce the query I recorded a macro and then used the code it produced. I then changed the URL to url, a string variable which holds the urls of the pages. The destion address was changed to destination, a range variable to store the destionation location, and the webTable was changed to table also a string variable to store the table number. This is shown below.

With ActiveSheet.QueryTables.Add(Connection:= _
url, Destination:= destination)
.Name = "q?s=%5EFTSE&m=L_137"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True.............................

View 2 Replies


ADVERTISEMENT

Modules In VBA

Feb 26, 2009

Can i know how many modules can be used in a VBA Program

View 9 Replies View Related

Combine The IF And OR Queries

Jan 8, 2009

Trying to write an IF query looking for multiple returns that would equal the same result.

I have a series of number where the last digit would result in the same return if the digit were 1 or 6, 2 or 7, 3 or 8, etc.

1 or 6 = 1
2 or 7 = 2

I have been trying unsuccessfully to combine the IF and OR queries

View 12 Replies View Related

Using Lookups & IF Queries Together?

Dec 28, 2012

I'm currently working on a side project for work that I believe will save many man hours as at the moment we're using paper and calculators!!! I'm scheduling buys. I've worked out formulas and formats to show how much we should buy and how they should be split (for example for UK purchases we buy x amount and split it 10% 90%). However, the dates of delivery are different. See below:

PORT L'poolPORT HKPORT Portsmouth
1.113-Aug-1206-Aug-1230-Jul-12
1.210-Sep-1203-Sep-1227-Aug-12
2.103-Sep-1227-Aug-1220-Aug-12
2.201-Oct-1224-Sep-1217-Sep-12
3.124-Sep-1217-Sep-1210-Sep-12
3.222-Oct-1215-Oct-1208-Oct-12

Campaign 1 first buy (1.1) I know that my product is sailing from port HK. Therefore I want it that in the 'delivery date' cell, it returns 6/aug/12 (that's the first lot of 10%, and underneath it returns 3/sep/12) which the remaining 90%...2.2).

However, both the campaign number AND port options are variable (using a data validation drop down list). In effect meaning if I choose campaign 2 instead of campaign one, it'll return the dates 27/aug and 24 sep....if I then change the port to Portsmouth, the dates will be 20 aug and 17 sep.

I've attached a quick view of the schedule I've created. The yellow cells are where I want the dates to be returned.

ScheduleEX.jpg

View 4 Replies View Related

Precision Through Queries

Apr 28, 2009

I have a program that uses a query to grab data from overseas. I have an issue where some precision is apparently lost and I was curious if there was a way around this.

As an example of what is going on I have a specific piece of data I am tracking. The value is 14.9 in the SQL database and it's datatype there is a real of length 4. After grabbing this item from the query I checked the record set and the value is still 14.9. After it reaches the worksheet though it is displayed as 14.89999962. The destination cell is currently formatted as General but I have tried Text as well. Both produce the same results. As this tool is very general I would not have it formatted as a number as I don't know what I am getting back exactly.

I know computers store real/single values inprecisely but I see it everywhere else as 14.9. I would think Excel would display what I am seeing. Is there anyway around this short of formatting the cell as number with 1 decimal place?

View 4 Replies View Related

VBA Inputbox To Sql Queries

Jul 31, 2007

The report is a "template" that will be ran once a month every month and will look back at the previous month's data. What i've invisioned is writing a vb script to load on workbook open asking various questions via "inputbox()" method.

SET NOCOUNT ON
DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = '20070731 10:10:51.450'
SET @EndDate = '20070731 10:11:51.450'
SET ROWCOUNT 100
SET NOCOUNT OFF
SELECT EventTagName = EventHistory.TagName, Value
FROM EventHistory
INNER JOIN AnalogSnapshot ON EventHistory.EventLogKey = AnalogSnapshot.EventLogKey
INNER JOIN SnapshotTag ON SnapshotTag.SnapshotTagKey = AnalogSnapshot.SnapshotTagKey
WHERE SnapshotTag.TagName IN ('SysSpaceMain')
AND DateTime >= @StartDate
AND DateTime

View 9 Replies View Related

Parameter Queries In Vba

Mar 30, 2007

I want know how to pass a parameter through a cell for date in the following url

http://fc-web-phl1-101.phl1:8090/gp/...runReport.y=10

View 9 Replies View Related

Class Modules?

Oct 14, 2008

I'm wondering about class modules and what they can be used for etc etc? i want to continue developing my VBA and feel that this area is the next step?

View 2 Replies View Related

Ignoring 1 Of Two Modules

Jan 28, 2010

I have managed to get it almost done with lots of help from here the last issue I have is this:

The module I want transferred is working the assigning of the macro within that module to the button is working, however, when it gets to the FillSalesSheet section it opens the said workbook but then jumps to the module and the FillSalesSheet in that.

Module 1 which I would like ignored on the newly formed workbooks looks like this: ...

View 14 Replies View Related

Removing Modules

Nov 16, 2006

It seems like I am asking a question at least once a day. I searched the net and forums and could not find an answer to this question. Thanks to everyone for the help I am making a lot of progress because all of you. Basically, I have a read-only workbook which the user gets a prompt to save as a new workbook for editing purposes. I have a autorun macro so now when the user opens their workbook, it contains my autorun macro. I do not want this. Is there a way to remove modules so that the users copy has no macro information?

View 9 Replies View Related

On Open Run Two Modules

Apr 16, 2008

I have two modules I wish to run when I open a workbook. The reason I have them as modules is they are required to be run manually, also.

Is it possible for me to set a Workbook_Open() sub that will run these two modules?

The modules names are Module1 and Module2.
The modules stipulate what sheets etc they have to act on, I only need the modules to be initiated.

View 9 Replies View Related

Export All Modules

Feb 11, 2008

I had a search and look around, but couldn't find any information on how to quickly (automatedly) export all the modules in a workbook to text files.

View 3 Replies View Related

Delete All Modules

Apr 17, 2008

I was looking for code that actually deletes ALL modules in the VBA code after I terminate a particular program.

View 2 Replies View Related

Web Queries For Multiple Pages?

Dec 10, 2008

My question is about webqueries... specifically how to set up a query that will automatically fetch data on different pages (same data, but includes page 2, page 3, page 4, etc )

I've just figured out how to import a "new web query," but it seems like I won't be able to import 63 pages of it unless I do all of them by hand.

View 7 Replies View Related

How To Create Reports And Queries

Jan 19, 2013

i would like to create reports and queries in excel just like in access is this possible or do you import a layout,i have a sheet that has data on i would like to be able to pick just one row or mutiple rows and print them off could i save them to a menu to use over and over again,would i use a userform to search for these or can it be done otherways ,have seen pivot tables but seem bit complicated

View 2 Replies View Related

Multiple Web Queries In One Column

Mar 20, 2014

I'm new to macro and have tried copy from others who have posted before but it don't seem to lead to anywhere.

I'm trying to automated a column of web query (sheet1,column A), a batch of listing site with no tables. with the results in sheet2.

Looping part as well. Also, is it possible to just extract <title> from the page source.

Here's what I have so far.

PHP Code: 

Sub Macro1()
'
' Macro1 Macro
'
'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;" & Sheets("Sheet1").Range("A2") _
        , Destination:=Range("B2"))
 
[Code] ........

Tried changing the destination from

Destination:=Range("B2")) to Destination:=Range("Sheet2!$A$2"))

But keep getting error to change destination.

View 1 Replies View Related

External Data Queries

Apr 1, 2008

I use external data queries in excel. That's how I look up data in my access databases because I have so many access and SQL databases it's just eiser to be able to do quick queries on multiple databases at the same time in one spreadsheet. And, I can save the external data query as a tool to use in future queries. I have tons of tools and external data query is the foundation of most of them.

What bugs me is EDITING data.

If I want to do some light simple editing in an SQL database I am required to use a linked table in Access or SQL Studio Express Manager. Great programs, but I want to integrate!

Is there no way to make excel a database editor? I can retrieve data from any database or program with excel just fine, but is there a way to use excel to DIRECTLY EDIT the data in an external database with EXCEL like I can in access linked tables?

View 9 Replies View Related

List Of Web Site Queries

Apr 7, 2009

i have 306 web pages listed in sheet 1, A1:A306

how can i get a macro to open each and scrape a piece of info from each, and then store in a row in sheet 2?

View 9 Replies View Related

SQL Queries To Non-contiguous Range

Oct 3, 2009

I want data to columns A, C and E, while I have important data in columns B and D. Should I make three queries? Should I make query and save the results to temporary place and then move all the results to those columns A, C and E?

Right now the copying happens like this:

If Not rsData.EOF Then
rngTarget.CopyFromRecordset rsData
Else
MsgBox "No records returned.", vbCritical
End If

So should I do
1) One query and move everything in the right places
2) Multiple queries
3) Something else

Does this depend a lot about how many results I expect? I'd say likely about 100, maybe less than 1500, never more than 10000

View 9 Replies View Related

Compile A Web Page To Which There Are Many Many Queries?

Feb 10, 2010

how would you compile a web page to which there are many many querys?
i.e a website that has links to results

View 9 Replies View Related

Making Web Queries Recursive

Jun 8, 2006

Hello folks! Here's to hoping I can eventually be a source of information rather than questions. But enough about me - on to the topic at hand.

I have a single-source web query that I'd like to expand.

Here's what I have in the IQY file:

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes" ...

View 9 Replies View Related

Sort Multiple Web Queries

Nov 10, 2006

In short I have a yahoo query that loop through about fifty or so stock symbols. The query data is in column A to G starting with: Date, open,high,low ,close Adj. Now I have my Destination set up like so “Destination:= Range("A65536").End(xlUp).Offset(3))” for 3 row space between is retrieval

The problem is my: xlAscending

Selection.Sort Key1:=Range("A65536"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Ascending only convert the first query to Ascending the rest of the data remains Descending, how do I get all my query data to convert to Ascending using Date.

View 7 Replies View Related

Keeping Last Row Variable Across Modules?

Jun 11, 2014

I'm trying to make it so that a lastrow I defined in one module will still be defined in another macro.

My background for this - my macro is too large for one module, therefore, I split it in two. However, the new module uses defined variables (multiple lastrow definitions) from the original module.

So, is there a way to make it so when I originally define a lastrow in one module, other modules will recognize it?

View 8 Replies View Related

Call Modules From Array?

Sep 14, 2012

I have a number of modules that I want to call is it possible to call them from an array

For example

myarray = Array("Outstanding_Per_Agent", "Unique_Records")

Call myarray

This doesn't work as it says it expects a sub function or property

Do I need to define "myarray" as something or is it even possible.

View 2 Replies View Related

How To Dim A Response (from Input Box) Throughout Different Modules

Jan 21, 2014

I'm working with a substantial amount of code (which, due to its size, has been spread out into different modules). Whenever I transition from one module to the other, I have placed a msg at the beginning of each module to prompt the user to simply insert an integer to signify which version of the automation that is run. The following is an excerpt of a sample msg

[CODE]
Dim Msg, Title As String
Dim MyInput As Integer
' Define message."

[Code].....

Where, whatever report is being run, will be the same throughout all of the modules (for example, if you run the "Day" Report" at the beginning, the rest of the automation should be run using the "Day Report" code, not the "Night Report").

Is there a way to do one of the following

1. Label the input of "Day Report" or "Night Report" at the beginning of the automation (where the above except of code is how that would be done), and that can then be the determinant through the rest of the modules

2. Set my code in a specific module to, when it completes, automatically go to the same style of report (Day or Night) in the next module.

View 1 Replies View Related

Running Modules Together On Same Worksheet

May 25, 2014

Can you run 2 modules at the same time on the same worksheet.

View 2 Replies View Related

Delete Multiple Modules

Sep 29, 2007

I have successfully rewritten all code in one workbook project. I have cut my Standard modules from 17 to just 4 modules.

Is there a way to remove all 17 modules at once so I can replace them with the 4 new ones?

I know that right clicking on the module and then click on "Remove...." will do it, but I would have to do that 17 times.

Not too bad if this was just one workbook to do. I have about 10 other books to do the same thing to. So that would be doing the right click 170 times.

I'm not even sure if this is possible. And if it is, I was thinking at probably having the code in a workbook open event to delete the Standard Modules??? Then I could just import the new modules.

View 9 Replies View Related

Vba: Difference Between Sheet And Modules

Aug 12, 2008

If I put:

Sub t1()
Worksheets("sheet1").Cells(1, 1).Value = "abc"
End Sub

on sheet1, it works. But if I put it on module1, then it does not work. What do I miss here?

View 9 Replies View Related

Pass Variable Between Modules

Dec 11, 2009

I created the following sub to signal when a macro in Module 1 is complete:


Public Sub Done()
Dim complete As Boolean
complete = True
End Sub
I placed this just before the end sub in the macro for which I am trying to detect that it has finished executing:


Call Done

End Sub
In the Sheet 1 Module, the code fails at the statement:


If complete = True Then
The error returned is "Variable not defined." All three subs are declared as Public. Why does the Sheet1 sub not recognize the variable "complete" from the Module 1 macro?

View 9 Replies View Related

Range As Variable For Use Between Modules

Sep 11, 2008

I want to set a variable for the range I want to copy so that the range can change between modules Sometimes I want to copy a1:x1 and Sometimes I want to copy a1:m1 what I did but it did not work

Dim myrange As range
myrange = a1:x1
range myrange.select
Selection.Copy

View 5 Replies View Related







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