Select date using vba in webpage date picker calendar

Vikas Kumar

New Member
Joined
Apr 2, 2017
Messages
49
Hi Friends,

I am trying to choose a date from webpage, by date picker calendar and fortunately reached for a mile with my current code,

_________________________________________________________________________________________

Driver.FindElementById("validtill").Click
d = Sheet1.Range("BA2")
n = Now()
'current month
If Range("BF1") = Month(n) Then
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 1 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 2 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 3 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 4 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 5 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 6 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 7 Then
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText("Next").Click
Driver.FindElementByLinkText(Day(d)).Click
End If

If Range("BF1") = Month(n) + 8 Then
Driver.FindElementByLinkText("Next").Click

_________________________________________________________________________________________

This works fine for 2018 but doesn't go ahead from 2018. Say I would like to select from today (2018) to 01-Jan-2019 then it falls on 31-Dec-2018 and don't step beyond. Here is a mirror copy of Inspect Element Page for better understanding, (Quoted Symbols because of was unable to post without it),

"<"td height="20" align="left" width="60%">"
"<"input type="text" id="validtill" value=" name="validtill" readonly="readonly" class="hasDatepicker">"
"<"span id="validTillError" style="color:red;font-weight: bold;">" "<"/span">"


Also linked image of webpage

Any help about how to get this done, Would be appreciated.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top