VBA date formatting

PGD15

Board Regular
Joined
Aug 5, 2016
Messages
137
Hi People.

I want to enter a value into a combo box on a webpage. I can access the combo box no problem and enter a value. ... my issue is the value is a date and needs to be entered in a certain format which is dd-mm-yy. However as this range changes on a daily basis i cannot put

.document.getelementbyname("datefrom")(0).value = 01-01-01 (as this changes)
i need to do something like
.document.getelementbyname("datefrom")(0).value = worksheets("sheet1").range("a1") (to allow for the change)

however this picks up the time and other infomation regarding todays date when i only want it in my format.

Is anyone able to help me correct my date format into that of dd-mm-yy so i can enter this into my combo box :)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Wouldn't this work?:

Code:
.document.getelementbyname("datefrom")(0).value = format(worksheets("sheet1").range("a1"), "dd-mm-yy")
 
Upvote 0

Forum statistics

Threads
1,216,179
Messages
6,129,338
Members
449,504
Latest member
Alan the procrastinator

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