Paste Special Values based on the date

timmcl_7

New Member
Joined
Dec 13, 2010
Messages
6
Hi,

I have a workbook which contains lots of formula and is therefore very large (about 70 mb). The sheet pulls information from field instruments every hour of every day for the entire year.

I want to write a macro, that loops through a range (B5:B8764) and copies the entire row if the value in column B is less than =NOW() - 7 days. The copied rows should then be pasted with values only exactly where they were located e.g. row 5 should be pasted back to row 5 the only difference being only the values will be pasted.

Any help would be much appreciated.

Regards
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try this:

Code:
Sub Macro1()
    Dim Dt As Range
    For Each Dt In Range("B5:B8764")
        If Dt.Value = Int(Now()) - 7 Then
            Dt.EntireRow.Copy
            Dt.EntireRow.PasteSpecial (xlPasteValues)
        End If
    Next
End Sub
 
Upvote 0
Try code below

Code:
Sub Macro1()
    Dim Dt As Range
    For Each Dt In Range("B5:B8764")
        If DateValue(CDate(Dt.Value)) = DateValue(Int(Date) - 7) Then
            Dt.Value = Dt.Value
        End If
    Next
End Sub

Does it help?

Biz
 
Upvote 0

Forum statistics

Threads
1,207,097
Messages
6,076,556
Members
446,213
Latest member
bettigb

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