Date Serial VBA

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all, I m using Excel 2007

Can anyone help me please on this issue

Column E:E is populated with Dates IE 12/06/12
In Column AP:AP I need to show as June 12 as a TEXT using the data from column E:E.

IE
12/06/12 June 12
14/12/12 Dec 12
09/02/11 Feb 12

Etc

This needs to be changed using VBA code and I think it can be done using Date Serial but I am unsure how to complete this.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    Range("AP" & i).Value = Format(Range("E" & i).Value, "mmmm yy")
Next i
End Sub
 
Upvote 0
Or:

Code:
With Range("AP1:AP" & Range("E" & Rows.Count).End(xlUp).Row) 
       .FormulaR1C1 = "=TEXT(RC[-37],""mmm yy"")" 
    .NumberFormat = "@"   
     .Value = .Value
End With

Dom
 
Last edited by a moderator:
Upvote 0
Cheers Vog, I'm pretty sure I added them and they vanished. I also then couldn't edit the post for some reason.

Dom
 
Upvote 0
Thank you both for your reply, Domski your code works a treat the first time but unless I reformat the column as a date format before re running the code again it just brings over the TEXT Calculation
=TEXT(RC[-37],"mmm yy")

<tbody>
</tbody><colgroup><col></colgroup>
 
Upvote 0
Fair point:

Code:
With Range("AP1:AP" & Range("E" & Rows.Count).End(xlUp).Row)
    .NumberFormat = "General"
    .FormulaR1C1 = "=TEXT(RC[-37],""mmm yy"")"
    .NumberFormat = "@"
    .Value = .Value
End With

Dom
 
Upvote 0
That's how I solved it also, many thanks again for your help, I see you have posted loads on this site, 6,953 since 2005, That's dedication
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

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