Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default First day of month

A cell in an Excel workbook contains a date. I want to write macro code to
generate, in another cell, the date of the first day of the next month.



I was going to use the Excel EOMONTH function, but Excel 2002, does not seem
to support the function. I can generate the date using the DATE function,
and I tried using Application.WorksheetFunction in my macro, but it did not
work with the Excel DATE function.



Any suggestions for macro code that will generate the first day of the next
month would be appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 13
Default First day of month

=EOMONTH(C4;0)+1
where C4 is your date ? format it of course as you wish

tomek

Użytkownik "Dianne Groom" napisał w wiadomości
...
A cell in an Excel workbook contains a date. I want to write macro code to
generate, in another cell, the date of the first day of the next month.



I was going to use the Excel EOMONTH function, but Excel 2002, does not
seem to support the function. I can generate the date using the DATE
function, and I tried using Application.WorksheetFunction in my macro, but
it did not work with the Excel DATE function.



Any suggestions for macro code that will generate the first day of the
next month would be appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 13
Default First day of month

ups.
Analysis ToolPack must be on

tomek

Użytkownik "tomek gomek" napisał w wiadomości
...
=EOMONTH(C4;0)+1
where C4 is your date ? format it of course as you wish

tomek

Użytkownik "Dianne Groom" napisał w wiadomości
...
A cell in an Excel workbook contains a date. I want to write macro code
to generate, in another cell, the date of the first day of the next month.



I was going to use the Excel EOMONTH function, but Excel 2002, does not
seem to support the function. I can generate the date using the DATE
function, and I tried using Application.WorksheetFunction in my macro,
but it did not work with the Excel DATE function.



Any suggestions for macro code that will generate the first day of the
next month would be appreciated.




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,391
Default First day of month

Assuming you have a date in A1, in another cell enter:

=DATE(YEAR(A1),MONTH(A1)+1,1)

VBA is similar, but use DateSerial instead of Date.

As for EOMONTH, this is supplied by the Analysis Tool Pack add-in, which may
not be installed. Check ToolsAddins in Excel.

NickHK

"Dianne Groom" wrote in message
...
A cell in an Excel workbook contains a date. I want to write macro code

to
generate, in another cell, the date of the first day of the next month.



I was going to use the Excel EOMONTH function, but Excel 2002, does not

seem
to support the function. I can generate the date using the DATE function,
and I tried using Application.WorksheetFunction in my macro, but it did

not
work with the Excel DATE function.



Any suggestions for macro code that will generate the first day of the

next
month would be appreciated.




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 180
Default First day of month

Try the below code

Dim mDate As Date
Dim mStr
mDate = DateAdd("m", 1, Range("L3").Value)
mStr = "01-" & Format(mDate, "mmm-yy")
Range("M3").Value = Format(mStr, "dd-mmm-yy")

Hope this helps!!
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"Dianne Groom" wrote:

A cell in an Excel workbook contains a date. I want to write macro code to
generate, in another cell, the date of the first day of the next month.



I was going to use the Excel EOMONTH function, but Excel 2002, does not seem
to support the function. I can generate the date using the DATE function,
and I tried using Application.WorksheetFunction in my macro, but it did not
work with the Excel DATE function.



Any suggestions for macro code that will generate the first day of the next
month would be appreciated.





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default First day of month

On Fri, 27 Jul 2007 14:24:53 +0800, "Dianne Groom"
wrote:

A cell in an Excel workbook contains a date. I want to write macro code to
generate, in another cell, the date of the first day of the next month.



I was going to use the Excel EOMONTH function, but Excel 2002, does not seem
to support the function. I can generate the date using the DATE function,
and I tried using Application.WorksheetFunction in my macro, but it did not
work with the Excel DATE function.



Any suggestions for macro code that will generate the first day of the next
month would be appreciated.


Sub FirstOfMonth()
Dim src As Range
Dim dest As Range

Set src = Range("A1")
Set dest = Range("A2")

If IsDate(src.Text) Then
dest.Value = src.Value - Day(src.Value) + 1
End If

End Sub

--ron
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default First day of month

"Ron Rosenfeld" wrote...
"Dianne Groom" wrote...
A cell in an Excel workbook contains a date. I want to write macro code
to generate, in another cell, the date of the first day of the next month.

....
Sub FirstOfMonth()

....
If IsDate(src.Text) Then
dest.Value = src.Value - Day(src.Value) + 1
End If

End Sub


That sets dest to the first day of the same month as src. For the next
month, it requires something like

dest.Value = src.Value - Day(src.Value) + 33 _
- Day(src.Value - Day(src.Value) + 32)


  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default First day of month

On Fri, 27 Jul 2007 21:36:55 -0700, "Harlan Grove" wrote:

"Ron Rosenfeld" wrote...
"Dianne Groom" wrote...
A cell in an Excel workbook contains a date. I want to write macro code
to generate, in another cell, the date of the first day of the next month.

...
Sub FirstOfMonth()

...
If IsDate(src.Text) Then
dest.Value = src.Value - Day(src.Value) + 1
End If

End Sub


That sets dest to the first day of the same month as src. For the next
month, it requires something like

dest.Value = src.Value - Day(src.Value) + 33 _
- Day(src.Value - Day(src.Value) + 32)


<Sigh. Thanks. I misread the question.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtract a future month from the current month to get remaining m. Fletch Excel Worksheet Functions 1 July 26th 07 04:29 PM
Retrieve data for previous 3, 6, 12 month given current month GB Excel Worksheet Functions 4 July 19th 07 11:58 PM
Create Month Timetable on a worksheet different month each works Courtney Excel Worksheet Functions 1 October 15th 06 11:48 AM
When using MONTH function on Blank Cell!! Returns Month=Jan! mahou Excel Discussion (Misc queries) 6 January 9th 06 02:46 AM
transfer cell $ amount to other sheet month-to-month without overc Colin2u Excel Discussion (Misc queries) 1 July 28th 05 02:36 AM


All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Š2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"