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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

WillR

Well-known Member
Joined
Feb 18, 2002
Messages
1,143
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
 

RoyinUK2000

Board Regular
Joined
Mar 26, 2002
Messages
79
I have tried that but it just returns an error stating bad parameter, excel expected different kind of value.


Any idea's peeps

Roy
 

WillR

Well-known Member
Joined
Feb 18, 2002
Messages
1,143
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 ...
 

Forum statistics

Threads
1,144,510
Messages
5,724,774
Members
422,576
Latest member
kayth891

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
Top