Sub RoundedRectangle1_Click()
Dim x As Integer
Dim F As Integer
Dim MyMonth As String
F = 1
' Set numrows = number of rows of data.
'NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
NumRows = 22
' Select cell a1.
Range("C2").Select
' Establish "For" loop to loop "numrows" number of times.
'For x = 1 To NumRows
For x = 1 To 1
F = F + 2
'Download Texas Railroad Commission Oil & Gas Data (TRRC Oil & Gas)
Dim ie As InternetExplorer
Set ie = New InternetExplorer
'Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://webapps.rrc.state.tx.us/PDQ/generalReportAction.do"
While ie.Busy
Wend
'Radio button: Select the initial view (0=Lease, 1=Operator, 2=FIELD, 3=District, 4=County)
Set ieRadio = ie.Document.all
'ieRadio.Item("viewType")(2).Checked = True
ieRadio.Item("viewType")(Worksheets("Launch").Range("F6").Value).Checked = True
'Select the Start Month
MyMonth = Worksheets("Launch").Range("D9").Value
Select Case MyMonth
Case "Jan"
MyMonth = "01"
Case "Feb"
MyMonth = "02"
Case "Mar"
MyMonth = "03"
Case "Apr"
MyMonth = "04"
Case "May"
MyMonth = "05"
Case "Jun"
MyMonth = "06"
Case "Jul"
MyMonth = "07"
Case "Aug"
MyMonth = "08"
Case "Sep"
MyMonth = "09"
Case "Oct"
MyMonth = "10"
Case "Nov"
MyMonth = "11"
Case "Dec"
MyMonth = "12"
End Select
ie.Document.getElementsByName("startMonth").Item.Value = MyMonth
'Select the Start Year (as yyyy format)
ie.Document.getElementsByName("startYear").Item.Value = Worksheets("Launch").Range("E9").Value
'Select the End Month
MyMonth = Worksheets("Launch").Range("D10").Value
Select Case MyMonth
Case "Jan"
MyMonth = "01"
Case "Feb"
MyMonth = "02"
Case "Mar"
MyMonth = "03"
Case "Apr"
MyMonth = "04"
Case "May"
MyMonth = "05"
Case "Jun"
MyMonth = "06"
Case "Jul"
MyMonth = "07"
Case "Aug"
MyMonth = "08"
Case "Sep"
MyMonth = "09"
Case "Oct"
MyMonth = "10"
Case "Nov"
MyMonth = "11"
Case "Dec"
MyMonth = "12"
End Select
ie.Document.getElementsByName("endMonth").Item.Value = MyMonth
'Select the End Year (as yyyy format)
ie.Document.getElementsByName("endYear").Item.Value = Worksheets("Launch").Range("E10").Value
'Radio Button: Choose the Well Type (0=Both; 1=Oil; 2=Gas)
Set ieRadio = ie.Document.all
ieRadio.Item("wellType")(Worksheets("Launch").Range("F12").Value).Checked = True
'Input the Field Name; the page requires two fields, the first one hidden. Set them both here.
ie.Document.getElementsByName("fieldNameData").Item.Value = Worksheets("Active Eagle Ford fields").Range("B" & F).Value
ie.Document.getElementsByName("fieldRegion").Item.Value = Worksheets("Active Eagle Ford fields").Range("C" & F).Value
ie.Document.getElementsByName("submit").Item.Value = "Submit"
ie.Document.getElementsByName("submit").Item.Click
ie.Visible = True
' Selects cell down 1 row from active cell.
ActiveCell.Offset(1, 0).Select
Next
End Sub