Macro To Create A Date Value

RoyinUK2000

Board Regular
Joined
Mar 26, 2002
Messages
79
I want to create a macro that will put a date into a specified cell. When the macro is ran i need the beginning of the current month in cell F1 and the end of the current month in cell F2.

Does anyone know how to do this

Thanks
Roy
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
On 2002-10-10 07:21, RoyinUK2000 wrote:
I want to create a macro that will put a date into a specified cell. When the macro is ran i need the beginning of the current month in cell F1 and the end of the current month in cell F2.

Does anyone know how to do this
probably a tidier way to do it but this works.

Code:
Sub Dates()
    
    Range("F1").Select
    ActiveCell.FormulaR1C1 = "=EOMONTH(TODAY(),0)"
    Range("F2").Select
    ActiveCell.FormulaR1C1 = "=EOMONTH((R[-1]C),-1)+1"
    Range("F1:F2").Select
    Selection.NumberFormat = "d-mmm-yy"
End Sub

=======================
hth

_________________
Will<img src=http://www.smilies.nl/dieren/pengy.gif>
Do NOT feed the Penguin!
This message was edited by WillR on 2002-10-10 07:55
 
Upvote 0
I have tried that but it just returns an error stating bad parameter, excel expected different kind of value.


Any idea's peeps

Roy
 
Upvote 0
SORRY...check your available functions....
Under dates, you should have the EOMONTH function. If you don't you will need to add an 'add-in' called 'analysis tool pack'

goto tools addins and tick the box for analysis tool pack - you may need to ask your administrator to add it ...
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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