ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Month/date problems. (https://www.excelbanter.com/excel-programming/327031-month-date-problems.html)

Hume

Month/date problems.
 

the following code does not give me the current month and
date when it creat the new sheet.
On my C1 cell it has the function of =DATE(YEAR(NOW
()),MONTH(NOW()),1). the new creat sheet on C1 cell start
with 01/01/2005 instead of the current month as
04/01/2005.
Can someone help?

---
Sub createsheets()
If MsgBox("Are you very very sure you want to do
this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month
(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = i
Next
End If
End Sub


Tom Ogilvy

Month/date problems.
 
Sub createsheets()
If MsgBox( _
"Are you very very sure you want to do this?", vbYesNo, _
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), _
Month(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets _
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = DateSerial(Year(date), _
Month(Date)+1,i)
Next
End If
End Sub

--
Regards,
Tom Ogilvy


"Hume" wrote in message
...

the following code does not give me the current month and
date when it creat the new sheet.
On my C1 cell it has the function of =DATE(YEAR(NOW
()),MONTH(NOW()),1). the new creat sheet on C1 cell start
with 01/01/2005 instead of the current month as
04/01/2005.
Can someone help?

---
Sub createsheets()
If MsgBox("Are you very very sure you want to do
this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month
(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = i
Next
End If
End Sub




Hummail.come

Month/date problems.
 

Thanks, But now the month Start at May/01/2005 instead
of April/01/2005.

-----Original Message-----
Sub createsheets()
If MsgBox( _
"Are you very very sure you want to do this?",

vbYesNo, _
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), _
Month(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets _
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = DateSerial(Year(date), _
Month(Date)+1,i)
Next
End If
End Sub

--
Regards,
Tom Ogilvy


"Hume" wrote in message
...

the following code does not give me the current month

and
date when it creat the new sheet.
On my C1 cell it has the function of =DATE(YEAR(NOW
()),MONTH(NOW()),1). the new creat sheet on C1 cell

start
with 01/01/2005 instead of the current month as
04/01/2005.
Can someone help?

---
Sub createsheets()
If MsgBox("Are you very very sure you want to do
this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month
(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = i
Next
End If
End Sub



.


Tom Ogilvy

Month/date problems.
 
Your code did Month(date) + 1.

In April, that is May. If you want April, remove the + 1. Doing the best I
can with what you provide.

--
Regards,
Tom Ogilvy

"Hummail.come" <sky@hot wrote in message
...

Thanks, But now the month Start at May/01/2005 instead
of April/01/2005.

-----Original Message-----
Sub createsheets()
If MsgBox( _
"Are you very very sure you want to do this?",

vbYesNo, _
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), _
Month(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets _
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = DateSerial(Year(date), _
Month(Date)+1,i)
Next
End If
End Sub

--
Regards,
Tom Ogilvy


"Hume" wrote in message
...

the following code does not give me the current month

and
date when it creat the new sheet.
On my C1 cell it has the function of =DATE(YEAR(NOW
()),MONTH(NOW()),1). the new creat sheet on C1 cell

start
with 01/01/2005 instead of the current month as
04/01/2005.
Can someone help?

---
Sub createsheets()
If MsgBox("Are you very very sure you want to do
this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month
(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets
(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = i
Next
End If
End Sub



.





All times are GMT +1. The time now is 09:53 PM.

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