Copy Info from one sheet to another if a certain criteria is met

rclaudia58

New Member
Joined
Jul 1, 2008
Messages
1
Hello,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
I need help with the following problem:<o:p></o:p>
I have two sheets: Daily Report and Monthly Totals.<o:p></o:p>
In the first sheet I have some statistic information. It is a small table that contains the following disciplines (B5 to B15), Data A (C5 to C15), Data B (D5 to D15), the date in Cell C18 and this info will be updated on a daily basis (I had built a macro that is doing that). The problem is that on the second page I have a table which contains the same disciplines but listed from 1 July until 31 July. I need a macro that will copy in the cell B4(Monthly Totals) the info contained in C5(Daily Report) and in the cell B5(Monthly Totals) C5-D5(Daily Report) in the respective column (meaning the one that has the same date as in C18 (Daily Report).<o:p></o:p>
This is the Macro that I put up together but somewhere I made a logical mistake since it is not returning the values correctly.<o:p></o:p>
Thank you for your help!<o:p></o:p>

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Data As Date
Data = Worksheets("Daily Report").Cells(18, 3).Value
i = 1
k = 4
Do
i = i + 1
For j = 4 To 24 Step 2
k = k + 1
If Cells(3, i).Value = Data Then Cells(j, i) = Worksheets("Daily Report").Cells(k, 3).Value: Cells(j + 1, i) = Worksheets("Daily Report").Cells(k, 3).Value - Worksheets("Daily Report").Cells(k, 4).Value
Next j
Loop Until i = 33
End Sub
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
It would have been helpful if you had given a small extract of the two sheets.
The configaration of sheet " montly totals" is not clear. Is it like the sheet below Please try to post the second sheet "monthly totals" using heml maker.
Book1
ABCDEFG
1discipline1-Jul2-Jul3-Jul4-Jul5-Jul
2
3
4
5a
6s
7d
8f
9g
10h
11j
12k
13l
14p
15o
monthly totals
 

Watch MrExcel Video

Forum statistics

Threads
1,122,186
Messages
5,594,745
Members
413,929
Latest member
Hypatia

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
Top