Find today's date and copy/paste as value adjacent cells

emoandy05

Board Regular
Joined
Sep 4, 2013
Messages
60
Hello,

Starting in cell I12, I have dates listed. In cells J12:AO12 i have data that pulls in based on formulas. I would like a macro that will find today's date in column I, starting in cell I12, and will copy and paste as values the data in the adjacent cells in columns I:AO, starting with J12:AO12.

Thank you!

Emerson
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try:
Code:
Sub TodayDate()

    Dim LR  As Long
    Dim rng As Range

    Application.ScreenUpdating = False
    
    LR = Cells(Rows.count, 9).End(xlUp).row

    Set rng = Cells(12, 9).Resize(LR - 11).find(what:=Date, LookIn:=xlValues, lookat:=xlWhole).Offset(, 1)
    If Not rng Is Nothing Then rng.Resize(, 32).Value = rng.Resize(, 32).Value
    
    Application.ScreenUpdating = True
        
    Set rng = Nothing
    
End Sub
 
Last edited:
Upvote 0
Thank you very much. Works well. Would you mind explaining how
Code:
If Not rng Is Nothing Then rng.Resize(, 32).Value = rng.Resize(, 32).Value
works?
 
Upvote 0
You're welcome.

This line:
Rich (BB code):
Set rng = Cells(12, 9).Resize(LR - 11).find(what:=Date, LookIn:=xlValues, lookat:=xlWhole).Offset(, 1)

Tries to find the date in range I12:I<last row=""> and if it find's it, sets the rng variable to the 1st column to the right using .Offset
Rng initialises as an empty range object.
Rich (BB code):
If Not rng Is Nothing Then rng.Resize(, 32).Value = rng.Resize(, 32).Value

The line above tests if rng is not Nothing. If it's Not nothing, i.e. it has found a matching date (then offset to the right by one column) then resize that cell by 32 columns and make them all equal to the rng's value</last>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top