Posts

Showing posts from November, 2014

Get the Values of all SPAN Elements with the same Class Name using jQuery

I am using the snippet below on one of my blogs in blogger to dynamically get the classname of a span element which contains a text of the post ID of the entry and process the iframe tags within that element. $(document).ready(function(){ $.each($('span.post-id'),function(i,v){ var s = $(this).text(); getiFrame(s); //this is a separate function to process iframe tags. }); });

How to Extract Data From HTML (.aspx) website into Excel using VBA

Image
In this example I used the following VBA code to extract the data stored in a script variable. You can see the example data from an HTML file at the end of this post. Below is the snapshot of the page that I was trying to extract data from. VBA CODE: '******************************************************** ' DESCRIPTION: GET DATA FROM TABLE OF A .ASPX WEBSITE ' BY: CROMWELL D. BAYON ' EMAIL: OMELSOFT@GMAIL.COM '******************************************************** Sub GetOfflineData() Dim file As String, Data As String Dim delimQ As String Dim lineContentLoc As Long delimQ = Chr(34) file = Application.ActiveWorkbook.Path & "\Source of Select.html" Open file For Input As #1 Do Until EOF(1) Line Input #1, linefromfile 'Check only the line containing this pattern (var best_idear_data =[) If InStr(1, linefromfile, "var best_idear_data =[...

Count number of occurrence in a string using Excel VBA.

The following code snippet allows you to get the number of text occurrences in a string using VBA in Excel. Function StringCountOccurrences(strText As String, strFind As String, _                                 Optional lngCompare As VbCompareMethod) As Long Dim lngPos As Long Dim lngTemp As Long Dim lngCount As Long     If Len(strText) = 0 Then Exit Function     If Len(strFind) = 0 Then Exit Function     lngPos = 1     Do         lngPos = InStr(lngPos, strText, strFind, lngCompare)         lngTemp = lngPos         If lngPos > 0 Then             lngCount = lngCount + 1             lngPos = lngPos + Len(strFind)         End If     Loop Until lngPos = 0     StringCountOccurrences = lngCount End Functi...