• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Apply date format any separate column in excel VBA

achu

Member
Dear Sir,

how to apply date format any selected columns in excel VBA.

Thank you advance for your kind help

Thanks
Achyutanand Khuntia
 
If you want to apply to a known range
Code:
Dim MyRng As Range
Set MyRng = Range("H2:H20") 'Set Range as appropriate

Dim DateString  As String
DateString = "dd mmm yy" 'Customise date striing as you please

MyRng.NumberFormat = DateString

If you want to apply to an entire column
Code:
Dim MyRng As Range
Set MyRng = Range("H:H") 'Set as appropriate

Dim DateString  As String
DateString = "dd mmm yy" 'Customise date striing as you please

MyRng.NumberFormat = DateString

If you want to select the entire column based on the current cell
Code:
Dim MyRng As Range
Set MyRng = Columns(Selection.Column) 'Set by current selected cell address

Dim DateString  As String
DateString = "dd mmm yy" 'Customise date striing as you please

MyRng.NumberFormat = DateString
 
Last edited:
Back
Top