ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   date/year method (https://www.excelbanter.com/excel-programming/293123-date-year-method.html)

JohnE

date/year method
 
I am wanting the current month and year to show in range
(A6) thru the use of code and a button. But, I am having
difficulty using the month(date) as it returns a number
for the month. I haven't tried to add the year until I
get the month figured out.
How do I go about getting the Month - Year into a cell
from code?
Thanks for any assistance.
*** John

Frank Kabel

date/year method
 
Hi
one way:
sub month_year()
dim rng as range
set rng = activesheet.range("A6")
rng.value = now
rng.numberformat = "MMM - YYYY"
end sub

assign a button to this macro


--
Regards
Frank Kabel
Frankfurt, Germany

JohnE wrote:
I am wanting the current month and year to show in range
(A6) thru the use of code and a button. But, I am having
difficulty using the month(date) as it returns a number
for the month. I haven't tried to add the year until I
get the month figured out.
How do I go about getting the Month - Year into a cell
from code?
Thanks for any assistance.
*** John



All times are GMT +1. The time now is 10:19 PM.

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