How to fill selected cells with given data?

Solved/Closed
Jussi - Feb 26, 2010 at 05:34 AM
 hockey50 - Feb 27, 2010 at 01:35 PM
Hello,
I often need to fill cells with a date of production.
What kind of a macro would be usefull in this situation so that I could just select the cells that I need to fill and just enter the date of productions?

2 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Feb 26, 2010 at 06:16 AM
Depends on your requirement, If you want to enter todays days, you can press control and ;
I

If the cells location is same and scattered across the sheet, then you can write a macro that looks at those cell and put the date there
0
Thanks for such a quick reply!
My situation is the latter this time, so the cells are scattered all over the sheet and I do not give todays date, usually yesterdays...

I have no idea what that macro would look like.
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766 > Jussi
Feb 26, 2010 at 07:59 AM
Again depends on you situation

If cells can be any place in the sheet and each time at a different location, then either you have to type in the date or have to define the address of each cell on a sheet from where macro would know what the address to target.
0
Jussi > rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022
Feb 26, 2010 at 09:52 AM
Could I first select the cells that I need to fill and that way show to macro what cells needs to be updated with the given data (the date in this case).
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766 > Jussi
Feb 26, 2010 at 12:42 PM
Yes possible

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

Sub fixDate()
    
    Dim vValue As Variant
    
    'default date is yesterday
    vValue = InputBox("Enter Date", "Date", Date - 1)
    
    
    For Each cell In Selection

        cell.Value = vValue 
    
    Next
    
End Sub
0
Jussi > rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022
Feb 26, 2010 at 12:54 PM
Thank you so much, this seems to work just as I tried to explain.
I dont know how to thank you enough.
0
My situation is the latter this time, so the cells are scattered all over the sheet and I do not give todays date, usually yesterdays...

http://www.newnfresh.com/index.html
0