Download Election Result 2015

'Macro Program to Download Election Result 2015
Sub ERMacro_of_Dwonload_Result()

Cells(1, 1) = "AC No"
Cells(1, 2) = "AC_Name"
Cells(1, 3) = "Result"
Cells(1, 4) = "Candidate"
Cells(1, 5) = "Party"
Cells(1, 6) = "Votes"
Cells(1, 7) = "Position"
ActiveSheet.Cells(2, 7).Formula = "=COUNTIF(B2:$B$2,B2)"
Rng1 = 2
 
  For i = 1 To 2
 
Lnk = "URL;http://eciresults.nic.in/ConstituencywiseU05" & i & ".htm?ac=" & i
n = "ConstituencywiseU05" & i & ".htm?ac=" & i

Cells(Rng1, 1) = i
   
    With ActiveSheet.QueryTables.Add(Connection:= _
        Lnk, Destination:= _
        Cells(Rng1, 4))
        .Name = n
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "10"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
 
    End With
     Cells(Rng1, 2) = Cells(Rng1, 4)
     Cells(Rng1, 3) = Cells(Rng1 + 1, 4)
    
    Rng1 = Range("D100000").End(xlUp).Offset(0, -1).Row
    Rng = "A" & Rng1 & ": d" & Rng1
    Range(Rng).Select
    Range(Selection, Selection.End(xlUp)).Select
    Selection.FillDown
   
    Rng1 = Range("D100000").End(xlUp).Offset(0, -1).Row
    Rng = "G" & Rng1
    Range(Rng).Select
    Range(Selection, Selection.End(xlUp)).Select
    Selection.FillDown
   
    Rng1 = Rng1 + 1
    Cells(Rng1, 4).Select
   
   
   Next i
  
End Sub
       
   

Comments

Popular posts from this blog

TDS Calculation System

VBA - Additional Controls Dialog Box "MISSING"

Loan EMI Calculator Dashboard