#1   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default Now()


Hello,

I am trying to use the below VBA code to show the words "YTD May" or the
month 45 days ago.

Something is not correct in my code, because after running it displays "YTD 5"

Range("i3").Value = "YTD " & Month(Now() - 45)

How can I correct the formatting of the Month in this code?

Thank You
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Now()

Hi

You can use the format function

Range("i3").Value = "YTD " & Format(Month(Date - 45), "mmm")


--
Regards Ron de Bruin
http://www.rondebruin.nl


"tjh" wrote in message ...

Hello,

I am trying to use the below VBA code to show the words "YTD May" or the
month 45 days ago.

Something is not correct in my code, because after running it displays "YTD 5"

Range("i3").Value = "YTD " & Month(Now() - 45)

How can I correct the formatting of the Month in this code?

Thank You



  #3   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default Now()

Thank You that helps the formatting. However, after inputing this
information, the month is always showing January. Why is this and how can I
get it to show May with the formula.

"Ron de Bruin" wrote:

Hi

You can use the format function

Range("i3").Value = "YTD " & Format(Month(Date - 45), "mmm")


--
Regards Ron de Bruin
http://www.rondebruin.nl


"tjh" wrote in message ...

Hello,

I am trying to use the below VBA code to show the words "YTD May" or the
month 45 days ago.

Something is not correct in my code, because after running it displays "YTD 5"

Range("i3").Value = "YTD " & Month(Now() - 45)

How can I correct the formatting of the Month in this code?

Thank You




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Now()

This may help you.

http://www.w3schools.com/vbscript/func_monthname.asp

"tjh" wrote in message
...

Hello,

I am trying to use the below VBA code to show the words "YTD May" or the
month 45 days ago.

Something is not correct in my code, because after running it displays

"YTD 5"

Range("i3").Value = "YTD " & Month(Now() - 45)

How can I correct the formatting of the Month in this code?

Thank You



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Now()

Oops

Range("i3").Value = "YTD " & Format(Date - 45, "mmm")

--
Regards Ron de Bruin
http://www.rondebruin.nl


"tjh" wrote in message ...
Thank You that helps the formatting. However, after inputing this
information, the month is always showing January. Why is this and how can I
get it to show May with the formula.

"Ron de Bruin" wrote:

Hi

You can use the format function

Range("i3").Value = "YTD " & Format(Month(Date - 45), "mmm")


--
Regards Ron de Bruin
http://www.rondebruin.nl


"tjh" wrote in message ...

Hello,

I am trying to use the below VBA code to show the words "YTD May" or the
month 45 days ago.

Something is not correct in my code, because after running it displays "YTD 5"

Range("i3").Value = "YTD " & Month(Now() - 45)

How can I correct the formatting of the Month in this code?

Thank You






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



All times are GMT +1. The time now is 12:03 AM.

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"