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.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
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 (