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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

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,181,684
Messages
5,931,408
Members
436,788
Latest member
Oteez

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