How to fill selected cells with given data?


I often need to fill cells with a date of production.
What kind of a macro would be useful in this situation so that I could just select the cells that I need to fill and just enter the date of productions?


Here is a macro. Give it a shot, but make sure that you have a backup before hand. Select the target cells first and run the macro
If you press cancel, it would wipe out all the data of selection. Not a good idea.

Use this. It will confirm before wiping out:

Sub fixDate()
    Dim vValue As Variant
    'default date is yesterday
    vValue = InputBox("Enter Date", "Date", Date - 1)
    If (vValue = "") Then
        confirm = MsgBox("Do you wish to wipe out data from selection ?", vbQuestion + vbYesNo)
        If confirm <> vbYes Then Exit Sub
    End If
    For Each cell In Selection
        cell.Value = vValue
End Sub


Thanks to rizvisa1 for this tip on the forum.
Published by aakai1056. Latest update on February 27, 2010 at 04:02 AM by aakai1056.
This document, titled "How to fill selected cells with given data?," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Excel - copy a "Comment Text" into "Cell T"
Excel - Formula based on the color of cell