VBA code to extract data from website by continuing number series of data - excel

I desperately need your help to extract data from this webpage, here I have to enter number and than it reflect the information. I want a macro that can enter value in that field and than extract data in excel.
This is the website address
http://exportefiling.fbr.gov.pk/igm/IGMview1.aspx
I will put number value in IGM field and it will show data that I need in excel, after that I will add next number in IGM field that will reflect data and that needs to be copied on excel. I need this loop to be continued to a desired number e.g. starting number is 11105 and ending value is 11200. Please help I cannot attach screen shot here.

You could try Selenium (although it is doable without). I have never used it in VBA, but it appears to be available on Github. The other way is using the COM interface (only available in Internet Explorer), but that is kind of an old fashioned solution, compared to Selenium.

Related

How to search a website using a range of cells in excel to extract specific data

I'm trying to search the website "capfriendly.com/players/" using a column of cells and import the "Cap Hit" value back into excel in the adjacent column for each.
I'm a complete beginner when it comes to programming, so I've mostly been trying to learn from previous questions such as this one: excel macro to search a website and extract results
I'm still pretty perplexed, especially with how to extract just the specific value I'm looking for. Any guidance would be greatly appreciated.
I don't know which version of Excel you work with.
Anyway you can try this :
Create a new sheet.
Go to Data in the ribbon to get external data and choose "From web".
Input the url of your page ie https://www.capfriendly.com/browse
After a moment you should retrieve "Results" data that you can load with or without structure modifications. You now have a data table in your new sheet.
You can now access it with Vlookup or similar function, with VBA code or with formulas, to put specific data on specific cells of specific sheets like you need to.
Hope it helps.

Looking for guidance on VB Code for Excel that will create action between two dynamic tables in each sheet.

I am trying to create a spreadsheet that allows me to keep track of a customer with general details (name, phone number, address...) bu then also keep a very specific list of all the products they have ordered. I want to be able to run reports on frequency of all details including what has been ordered. I have a bit of programming experience but not a whole lot of Excel experience so I know how I would write a program but not exactly how to do it in Excel. My thought is to have one sheet dedicated to the general specifications of the customer and then a second sheet that keeps track of the orders per customer. I want to be able to click on a hyperlink or something of the sort that will take me to the second sheet and automatically fill in the customer name. I want the first sheet to have the guest information running horizontally in rows but then the second sheet would have the names running horizontally on the top row and the orders would go down each column under the names. This way it keeps all of my sheets tidy and allows for me to run the type of reports I'm looking for. The main issue I'm having is figuring out a way to create a link that will do the action I want. I understand how to program but don't know Visual Basic very well but if someone was able to offer a similar code I would be able to decipher it and change it to my needs. Or if someone has a more efficient thought on how to set up the spreadsheet I'm all ears! Thanks a ton!
what you need is to create a pivot table with a data model.
The instructions are longer then what it actually takes!
here are few tutorials about the subject:
youTube video
MSDN instructions
PS don't write code in Excel unless strictly necessary. If it's a data issue, use data model

developing a front end app using excel spread sheets

We get at least 20 queries a day on an average from our clients, where in we have to open and look at data on 4 to 5 Excel sheets to answer them. questions such as what is my available balance, am i eligible for this etc. All our clients are connected to our intranet and have access to internet. I was wondering is there a way where we can develop a front end app (do not have budget for MS VB or any other) either in excel or any other to connect these 4 to 5 excel sheets to retrieve the data in response to queries (e.g. using perhaps some if and true/false queries). I am not an advanced Excel user but would be great for an advice from tech experts.
Yes, i wouldn't call it an app but consider a worksheet like a dashboard. You can have a cell for entering client name, and then use formulas to look up relevant information of the name entered. The cosmetic and arrangement of the information retrieved and published on the dashboard is up to you and of course do consider investing some time in the looks and feel if you want to enjoy using it.
Things you may consider are:
Place the files are kept and file name convention
because your dashboard will look for information in external workbooks, ensure that the files are saved in a fixed directory and have a specific file name. if the external files are updated from time to time by other folks, let them know too that they have to save it in a particular folder with a specific name format.
Properly structure the source of data
Format you data source into tables so that it is easier for use with formulas. Throw away titles if any in the data source worksheet. Use tools like "Table" under the INSERT tab. When data are properly organized, they can be easily looked up using formulas such as VLOOKUP, SUMIFS, MATCH-INDEX, and COUNTIF.
Be good with formulas
Since we have no budget for VB, then good formulas will be needed. There are plenty of help on the internet for this I think you'll have no problem in it.
Employ sanitary check measure
It is difficult to tell if our formula isn't functioning properly when we have no counter check measure. Certainly you want to give your clients accurate information. One way to check is, think of alternative ways to get the information wanted and check if it matches to the first way. Another way is to retrieve a sequence of related information to be put on the dashboard, then do simple calculation to check if the numbers add up. Use conditional formatting to highlight errors if necessary.
I think these are key consideration, there may be more, but this is what i can think of for the moment.

Refreshable Web Query using Excel 2010 and Parameters

I'm looking to pull into the XML feed from Feedburner's API. This is just a matter of writing the URL and using the "From Web" data connection in Excel.
https://feedburner.google.com/api/awareness/1.0/GetItemData?uri=RSSFEEDNAME&dates=2011-08-01,2011-08-05
This works fine (and is pretty fast).
Now, I'd like to be able to update two cells in the "dates" sheet to have it pull that range of data. This is done using parameters in the URL:
https://feedburner.google.com/api/awareness/1.0/GetItemData?uri=RSSFEEDNAME[]
Using the Excel UI, I can then assign the [] to any cell. However, no matter what I try, this doesn't work. I initially thought there might be some issue with the date format so I've worked myself to the point where I am entering into the cell, the exact copy (&dates=2011-08-01,2011-08-05) as text.
Each time, the feed pulls up with just the current days data (which is the default behavior when no dates are specified). It isn't giving an error (which it will do for relatively small infractions, like not having two-digit months) which makes me think it just simply isn't replacing the [] with the specified text. I'm also using this same method for a WebTrends Web Service query and gettign similarly frustrating results. I've read every how-to on web queries, and I'm following them exactly.
I can't find any place to see what the final URL Excel is requesting, so it's a bit of a shot in the dark. Any thoughts on next steps would be greatly appreciated!
Best,
Nathan
The answer was no to use the Web Query "wizard" and just do it by hand.
Open Notepad (or some text editor)
In the editor type the following four lines:
WEB
1
http://example.com/index.html?something=[]&somethingelse=[]
[BLANK]
Save it as anything with an .iqy extension.
Open Excel, go to the Data ribbon, and click "Existing Connections"
Click "Browse for More..."
Find the IQY file you made and click "Open"
Excel will then ask you where you want to put the resulting data, followed by prompts for each placeholder you entered in the URL. Those prompts let you either type in a value, or select a cell to act as the data.
I would have thought that dates should have been a named parameter and that you should link that to whichever cell has the date value(s).
The cell should just have 2011-08-01,2011-08-05 as its value as long as you create the named parameter dates and link it to that cell

How to export SSIS to Microsoft Excel without additional software?

This question is long winded because I have been updating the question over a very long time trying to get SSIS to properly export Excel data. I managed to solve this issue, although not correctly. Aside from someone providing a correct answer, the solution listed in this question is not terrible.
The only answer I found was to create a single row named range wide enough for my columns. In the named range put sample data and hide it. SSIS appends the data and reads metadata from the single row (that is close enough for it to drop stuff in it). The data takes the format of the hidden single row. This allows headers, etc.
WOW what a pain in the butt. It will take over 450 days of exports to recover the time lost. However, I still love SSIS and will continue to use it because it is still way better than Filemaker LOL. My next attempt will be doing the same thing in the report server.
Original question notes:
If you are in Sql Server Integrations Services designer and want to export data to an Excel file starting on something other than the first line, lets say the forth line, how do you specify this?
I tried going in to the Excel Destination of the Data Flow, changed the AccessMode to OpenRowSet from Variable, then set the variable to "YPlatters$A4:I20000" This fails saying it cannot find the sheet. The sheet is called YPlatters.
I thought you could specify (Sheet$)(Starting Cell):(Ending Cell)?
Update
Apparently in Excel you can select a set of cells and name them with the name box. This allows you to select the name instead of the sheet without the $ dollar sign. Oddly enough, whatever the range you specify, it appends the data to the next row after the range. Oddly, as you add data, it increases the named selection's row count.
Another odd thing is the data takes the format of the last line of the range specified. My header rows are bold. If I specify a range that ends with the header row, the data appends to the row below, and makes all the entries bold. if you specify one row lower, it puts a blank line between the header row and the data, but the data is not bold.
Another update
No matter what I try, SSIS samples the "first row" of the file and sets the metadata according to what it finds. However, if you have sample data that has a value of zero but is formatted as the first row, it treats that column as text and inserts numeric values with a single quote in front ('123.34). I also tried headers that do not reflect the data types of the columns. I tried changing the metadata of the Excel destination, but it always changes it back when I run the project, then fails saying it will truncate data. If I tell it to ignore errors, it imports everything except that column.
Several days of several hours a piece later...
Another update
I tried every combination. A mostly working example is to create the named range starting with the column headers. Format your column headers as you want the data to look as the data takes on this format. In my example, these exist from A4 to E4, which is my defined range. SSIS appends to the row after the defined range, so defining A4 to E68 appends the rows starting at A69. You define the Connection as having the first row contains the field names. It takes on the metadata of the header row, oddly, not the second row, and it guesses at the data type, not the formatted data type of the column, i.e., headers are text, so all my metadata is text. If your headers are bold, so is all of your data.
I even tried making a sample data row without success... I don't think anyone actually uses Excel with the default MS SSIS export.
If you could define the "insert range" (A5 to E5) with no header row and format those columns (currency, not bold, etc.) without it skipping a row in Excel, this would be very helpful. From what I gather, noone uses SSIS to export Excel without a third party connection manager.
Any ideas on how to set this up properly so that data is formatted correctly, i.e., the metadata read from Excel is proper to the real data, and formatting inherits from the first row of data, not the headers in Excel?
One last update (July 17, 2009)
I got this to work very well. One thing I added to Excel was the IMEX=1 in the Excel connection string: "Excel 8.0;HDR=Yes;IMEX=1". This forces Excel (I think) to look at all rows to see what kind of data is in it. Generally, this does not drop information, say for instance if you have a zip code then about 9 rows down you have a zip+4, Excel without this blanks that field entirely without error. With IMEX=1, it recognizes that Zip is actually a character field instead of numeric.
And of course, one more update (August 27, 2009)
The IMEX=1 will succeed importing data with missing contents in the first 8 rows, but it will fail exporting data where no data exists. So, have it on your import connection string, but not your export Excel connection string.
I have to say, after so much fiddling, it works pretty well.
P.S. If you are using a x64 bit version, make sure you call the DTExec from C:\Program Files\Microsoft SQL Server\90\DTS.x86\Binn. It will load the 32 bit Excel driver and work fine.
Would it be easier to create the Excel Workbook in a script task, then just pick it up later in the flow?
The engine part of SSIS is good but the integration with Excel is awful
"Using SSIS in conjunction with Excel is like having hot tar funnelled up your iHole in a road cone"
Dr. Zim, I believe you were the one that originally brought up this question. I totally feel your pain. I love SSIS overall, but I absolutely hate the limited tools that come standard for Excel. All I want to do is Bold the Heading or Row1 record in Excel, and not bold the following records. I have not found a great way to do that; granted I am approaching this with no script tasks or custom extensions, but you would think something this simple would be a standard option. Looks like I may be forced to research and program up something fancy for a task that should be so fundamental. I've already spent a rediculous amount of time on this myself. Does anyone know if you can use Excel XML with Excel versions: 2000/XP/2003? Thanks.
This is an old thread but what about using a flat file connection and writing the data out as a formatted html document. Set the mime type in the page header to "application/excel". When you send the document as an attachment and the recipient opens the attachment, it will open a browser session but should pop Excel up over the top of it with the data formatted according to the style (CSS) specified in the page.
Can you have SSIS write the data to an Excel sheet starting at A1, then create another sheet, formatted as you like, that refers to the other sheet at A1, but displays it as A4? That is, on the "pretty" sheet, A4 would refer to A1 on the SSIS sheet.
This would allow SSIS to do what it's good for (manipulate table-based data), but allow the Excel to be formatted or manipulated however you'd like.
When excel is the destination in SSIS, or the target export type in SSRS, you do not have much control over formatting and specifying how you want the final file to be. I have written a custom excel rendering engine for SSRS once, as my client was so strict about the format of final Excel report generated. I used 'Excel xml' to get the job done inside my custom renderer. May be you can use XML output and convert it to Excel XML using XSLT.
I understand you would rather not use a script component so perhaps you could create your own custom task using the code that a script contains so that others can use this in the future. Check here for an example.
If this seems feasible the solution I used was CarlosAg Excel Xml Writer Library. With this you can create code which is similar to using the Interop library but produces excel in xml format. This avoids using the Interop object which can sometimes lead to excel processes hanging around.
Instead of using a roundabout way to do this exercise of trying to write data to particular cell(s), format the cell(s), style them which is indeed a very tedius effort considering the support SSIS has for EXCEL, we could go the "template" way to do this.
assume we need to write data in the so & so cell with all the custom formating thats done on it. Have all the formatting in a sheet, say "SheetActual", Whereas the cells that will hold the data will actually have Lookups/ refrences/ Formulaes to refer to the original data that SSIS exports in a hidden sheet say "SheetMasterHidden" of the same Excel connection. This "SheetMasterHidden" will essentially hold the master data in default format that SSIS writes data to the excel. This way you need not worry about formatting the data runtime.
Formatting the Excel is a one time work "IF" the formatting dont change very often. If the format changes and the format is decided runtime this solution maynot go very well.
The answer is in the question. Over time, it became a progress status. However, there is SSRS that will create Excel files if you create TABLE presentations. It works pretty well too.

Resources