Find the count of each users questions vbs script or excel macro

I need help with a script that can go to each page like this

I have the user names in a file or column A in excel

http://tinyurl.com/c2z59lw

Then check the questions tab and get the count alone to column "B"

Please login to the site with these credentials to enter to the page

User name : EE-Test
Pass : EE-Test

thanks
LVL 11
bsharathAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
redmondbConnect With a Mentor Commented:
bsharath,

Yes, that one works, thanks.

As for me all i get are 0's
It's exactly as I mentioned earlier...
Consistently, if I have logged on from Excel (using "From Web") then the results are correct.
Had you done this immediately before running the macro?

My memory was correct - logging in from EE makes no difference. (Many sites have the facility to remember your password but not, apparently, your site.)

Please see the attached which includes the results.

Brian.
Check-URL-s-V---Results.xlsm
0
 
redmondbCommented:
Hi, bsharath.

Please see attached. The code is...
Option Explicit

Sub Check_URLS()
Dim i           As Long
Dim xResult     As Variant
Dim xCell       As Range
Dim xLast_Row   As Long

Sheets("Check URL's").Activate

xLast_Row = Range("A1").SpecialCells(xlLastCell).Row

If xLast_Row < 2 Then
    MsgBox ("No data found - run cancelled.")
    Exit Sub
End If

Range("B2:B" & xLast_Row).ClearContents

For Each xCell In Range("A2:A" & xLast_Row)
    
    If xCell <> "" Then
        i = i + 1
        xResult = Get_URL(xCell.Value)
    Else
        xResult = -1
    End If
    
    xCell.Offset(0, 1) = xResult
    
    Application.ScreenUpdating = True
    
Next

End Sub

Function Get_URL(xUrl As String) As Variant
Dim xTempSheet  As Worksheet
Dim xConnection As String
Dim xFound      As Range

Application.ScreenUpdating = False

Set xTempSheet = Sheets.Add
xConnection = "x" & Format(Now(), "hhmmss")

On Error Resume Next

    With xTempSheet.QueryTables.Add(Connection:="URL;" & xUrl, Destination:=Range("$A$1"))
        .Name = xConnection
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingAll
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With

On Error GoTo 0

If xTempSheet.Range("A1").SpecialCells(xlLastCell).Row = 1 Then
    Application.DisplayAlerts = False
        xTempSheet.Delete
    Application.DisplayAlerts = True
    Get_URL = -1
    Exit Function
End If

Set xFound = xTempSheet.Range("A:A").Find(What:="No of Questions : ", LookIn:=xlFormulas, LookAt:=xlPart _
                , SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
        
If xFound Is Nothing Then
    Get_URL = 0
Else
    Get_URL = Mid(xFound, 19, 9999)
End If

Application.DisplayAlerts = False
    xTempSheet.Delete
Application.DisplayAlerts = True

End Function

Open in new window

Regards,
Brian.
Check-URL-s-V.xlsm
0
 
bsharathAuthor Commented:
Can i have the column with just the names

Mike Atherton

should be
Mike%20Atherton

I tried with this one name and i get 0 where as it has 6 questions
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
redmondbCommented:
bsharath,

Sorry, I'm not clear about what you mean. Please post a sample entry

Edit: I tried "http://www.techyv.com/detail/Mike%20Atherton" and got 6 entries.

Thanks,
Brian.
0
 
bsharathAuthor Commented:
This URL
http://tinyurl.com/bs4jtua

has 6 questions but excel shows as "0"
0
 
redmondbCommented:
bsharath,,

Yes, I got six as well. Did you use the same URL as I did or the Tinyurl?

Edit: Please post the file you used.

Thanks,
Brian.
0
 
bsharathAuthor Commented:
Please check attached file
Check-URL-s-V.xlsm
0
 
redmondbCommented:
bsharath,

That worked fine for me. I wonder is this possibly a log-in issue? To check this, please do the following...
 - On the Ribbon's menu bar, click on "Data".
 - On the Data tab, click on "From Web".
 - In the Address box, enter  "http://www.techyv.com/detail/Mike%20Atherton" (no quotes!) and xlixk on Import.

Do you get the user's details or a log-in prompt?

Thanks,
Brian.
0
 
bsharathAuthor Commented:
I get a login prompt
0
 
redmondbCommented:
Thanks, bsharath, that explains our different results.

For the moment, use that log-in prompt to enter your user-id and password and then test the file. (The log-in should last until you restart Excel.) I'll look into passing the password.

Regards,
Brian.
0
 
redmondbCommented:
bsharath,

There are a number of (insecure) ways of passing user-id and password in a URL, however I can't get them to work on Techyv. I don't know whether this is caused by my web ignorance or with the site itself.

Assuming that the code is otherwise OK, you may wish to raise a new question in a more appropriate topic here or directly in Techyv.

Regards,
Brian.
0
 
bsharathAuthor Commented:
Please refer this

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Q_27976953.html

this code logs into the site. May be of help, not sure
0
 
redmondbCommented:
bsharath,

Thanks for the interesting link. I dropped the code for creating a new question and my version successfully logs into Techyv. However, this doesn't make any difference in Excel - loading the page there still shows the user as logged off.

Consistently, if I have logged on from Excel (using "From Web") then the results are correct. However, once I've logged out from there then I get the zero results.

If it's not acceptable to you to do a manual log-on, I'd recommend that you suggest in one of your open questions in which Robert is involved that he get involved here. Not only could he give you the definitive answer on logging on, but he may also have a faster way of getting the data back.

Regards,
Brian.
0
 
bsharathAuthor Commented:
Thanks Brian just left a note to Robert. Lets see if he can add help into this
0
 
bsharathAuthor Commented:
ID: 38729850
As in this
can you run the excel and send back with the results please

Also i will be already logged in in IE before i run this macro
0
 
redmondbCommented:
bsharath,

As in this
can you run the excel and send back with the results please.

Sorry, I don't understand this.

Also i will be already logged in in IE before i run this macro
That works with some sites, but, IIRC, not your one. Unfortunately the EE-Test login no longer works so I can't check this again.

Regards,
Brian.
0
 
bsharathAuthor Commented:
please try password EE-test

What i meant was the above excel can you run the macro so i can see if the results are right

As for me all i get are 0's
0
 
redmondbCommented:
Thanks, bsharath.
0
All Courses

From novice to tech pro — start learning today.