Copying yesterday's data.

Byrdwatcher

New Member
Joined
Mar 22, 2011
Messages
1
Hi,

I'm quite new to VBA and currently face the following. I have an excel workbook with many sheets grouped by month.

On Tuesday - Friday, i need to copy the value from column C for the previous day. On Monday, I need to copy Friday's value from Column C.
I then need to paste these values in another workbook.

Columns are listed like this.
Date(Column A) X(Column B) Y(Column C)

I've made a stab at the copy part but as of yet have only got to copying yesterday's date from Column A.

So, I need to
1. Search the workbook, not just the worksheet for yesterday's C value from Tuesday to Friday. And Friday's value on Monday.
2. Copy the corresponding data from the C Column and paste it to another Workbook, Test.xls

Thanks for any help.

Sub CopyRow()
Dim Rng As Range
Dim i As Range

With Worksheets("March_2011")
Set Rng = Range(.Range("A4"), .Range("A38").End(xlDown))

For Each i In Rng
If i = Date - 1 Then
i.Copy

End If
Next i
End With

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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