ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populate the sheet with date (https://www.excelbanter.com/excel-programming/306299-populate-sheet-date.html)

Patty2005[_7_]

Populate the sheet with date
 
I have a userform which takes input from user like start date and en
date.once I have those I want to find the difference and fill the star
date in A1 and A2 with next day, go on till I reach end date how do I d
that?

format of the date 08/06/2004


Code
-------------------
Sheet3.Activate
Range("B1").Select
ActiveCell.Value = frmCalendar.txtCalendar.Value
Do

ActiveCell.Offset(0, 1).Select
ActiveCell.Value = frmCalendar.txtCalendar.nextDay

Loop Until (ActiveCell.Value = frmCalendar1.txtCalendar1.Value
-------------------


If I do That it gives error type mismatch erro

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Populate the sheet with date
 
Hi Patty,

Sheet3.Activate

nowDate = frmCalendar.txtCalendar.Value

i=1
Do
With Cells( i,1)
.Value = nowDate
.numberformat = "m/dd/yyyy")
End With
nowDate = nowDate + 1
i = i + 1
Loop Until nowDate frmCalendar1.txtCalendar1.Value


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Patty2005 " wrote in message
...
I have a userform which takes input from user like start date and end
date.once I have those I want to find the difference and fill the start
date in A1 and A2 with next day, go on till I reach end date how do I do
that?

format of the date 08/06/2004


Code:
--------------------
Sheet3.Activate
Range("B1").Select
ActiveCell.Value = frmCalendar.txtCalendar.Value
Do

ActiveCell.Offset(0, 1).Select
ActiveCell.Value = frmCalendar.txtCalendar.nextDay

Loop Until (ActiveCell.Value = frmCalendar1.txtCalendar1.Value)
--------------------


If I do That it gives error type mismatch error


---
Message posted from http://www.ExcelForum.com/




Patty2005[_10_]

Populate the sheet with date
 
,

--
Message posted from http://www.ExcelForum.com


Patty2005[_9_]

Populate the sheet with date
 


--
Message posted from http://www.ExcelForum.com


Patty2005[_8_]

Populate the sheet with date
 
for some reason the code didn't work.it's not filling the values in th
worksheet.so I modified your code a little bit and made it t
work.Thanks for the help


Code
-------------------
Sheet3.Activate
Sheet3.Range("B1").Select
nowDate = frmCalendar.txtCalendar.Value
i = 1
Do
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until (IsEmpty(ActiveCell) = True)
ActiveCell.Value = nowDate
ActiveCell.NumberFormat = "mm/dd/yyyy"
nowDate = nowDate + 1
i = i + 1
Loop Until nowDate = frmCalendar1.txtCalendar1.Valu
-------------------


--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com