-2

I have a column in Excel that contains dates. Normally, I add a column next to it and use the formula =TEXT(A1,"MMM") to get the month abbreviation like “FEB”. How can I do the same with VBA and then paste the results as values (no formulas)?

expect to find faster and easir way

4
  • 1
    Iterate the range and use FORMAT: Range("A1") = Format(Range("A1"),"MMM") Commented Sep 2 at 21:05
  • Thank u, if the coulome have 100 cell how can apply them all not only A1 Commented Sep 2 at 21:17
  • You will need to do a loop and do each one individually Commented Sep 2 at 21:18
  • I will try it thank u Commented Sep 2 at 21:22

1 Answer 1

2

Use a Loop and Format:

Sub ChangeIt()

Dim rng as Range
Set rng = ActiveSheet.Range("A1:A100")

Dim rngArr as variant
rngArr = rng

Dim i as Long
For i = LBound(rngarr,1) to Ubound(rngarr,1)
    rngarr(i,1) = Format(rngarr(i,1),"MMM")
Next i

rng.NumberFormat = "General"
rng = rngarr

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.