• 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.

Printing Date in column

parth007

Member
Hello Members,

This seems to be very simple for all you experts.. but me finding it difficult...

I Have a column named as Date which will have current date..
so in VBA code i wrote...

Now()

But the user needs different format..
"MMDDYY" format of current date
Example - The output file should have date value = 230115
Please suggest
 
You mention VBA, but used a regular formula nomenclature, so I'm a little confused. Nevertheless, how to do it:
In column of interest, put formula:
=TODAY()
Then, format the cells to desired date format, or use a custom date format of
MMDDYY
 
Actually i converted the column to text & below code worked

Code:
Sheets("Resultant").Range("I2:I5000").Value = Format(Now(), "DD-MM-YY")
 
 ActiveSheet.Range("I2:I5000").NumberFormat = "@"
 
 Dim rng As Range, cell As Range
  Set rng = ActiveSheet.Range("I2:I5000")
  For Each cell In rng
  cell = WorksheetFunction.Substitute(cell, "-", "")
  Next
 
Code:
Sheets("Resultant").Range("I2:I5000").Value = Format(Now(), "DD-MM-YY")
Dim rng As Range, cell As Range
  Set rng = ActiveSheet.Range("I2:I5000")
  For Each cell In rng
  cell = WorksheetFunction.Substitute(cell, "-", "")
  Next
This code worked
Using this code will may give you the required format but you will lose the date with a number. I would suggest you to keep the date intact as that will help you do lot of things, like filter on month basis.

Regards,
 
Back
Top