Copy and paste (formats and formula) based on number in another cell

Dan88

Active Member
Joined
Feb 14, 2008
Messages
275
Office Version
  1. 365
Platform
  1. Windows
Hello excel community. I am in need of some VBA help and hope to find some answers here.
I am attempting to copy a range of data containing yesterday's date and paste (formula and formula) above the old data. So every day i will be updating my sheet by 1 day and have the newest data pasted on top of the old data (previous day).

For example the current data below sits on A11-E14. Tomorrow i want to copy all of yesterdays' data and paste on top of the below but under line A10. The original data set may change day over day, so i think setting the date as a copy criteria is the best approach.

[TABLE="width: 140"]
<tbody>[TR]
[TD="align: right"]1/10/2018[/TD]
[TD] A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD="align: right"]1/10/2018[/TD]
[TD] E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[/TR]
[TR]
[TD="align: right"]1/10/2018[/TD]
[TD] I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD="align: right"]1/10/2018[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[/TR]
</tbody>[/TABLE]


Is there such a VBA that can help me accomplish? i tried piecing together a bunch of codes i found but not of which can be catered to how i need it to work.

MUCH MUCH appreciated.
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Actually, i found the below but i think it may need some tweaking:

as oppose to a set last 3 rows, can I get a message asking me the last "X" rows to copy starting from A11 and paste below A10?

Thanks

Sub CopyLast3UsedRows()
Dim rLast3Rows As Range

With ActiveSheet.Cells
Set rLast3Rows = .Find(What:="*", After:=.Cells(1, 1), LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False).Offset(-3, 0).Range("A1:A3").EntireRow
rLast3Rows.Copy Destination:=rLast3Rows.Offset(4, 0)
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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