VBA to hard copy a value from a stationary cell to another cell based on a date

armchairandy

Board Regular
Joined
Mar 27, 2012
Messages
53
I have been wracking my brain and cannot see how I can do this:

I have a report updated weekly

Report Date
01/03/19

Value for that week
200

i have a set of weekly dates in columns with the total for each week

ie

"I" "J" "K" "L" "M" "N" and so on.........
01/02/19 08/02/19 15/02/19 22/02/19 01/03/19 08/03/19
20 50 150 180

What I need is I assume some vba code to take the 200 and put it in Column "M" as its the same date. But the code would need to do this each week after I input the value & not over write previous data in the columns. It would I know be simpler just to manually put the value against the column date , but the form has multiple users who are basically very lazy!, and want the whole process automated.


Any help would really be appreciated. I'm not fluent in VBA so please be patient.

Andrew
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try this, which assumes your date is in B2 and the total in C2:

Code:
Sub Macro1()
Dim iCol As Integer
Range("m1").Activate
For iCol = 0 To 100
    If ActiveCell.Offset(0, iCol).Value = Range("b2").Value Then
        ActiveCell.Offset(1, iCol).Value = Range("c2").Value
        Exit For
    End If
    If iCol = 100 Then
        MsgBox "Date not found in row 1"
    End If
Next iCol
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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