Automatically append data to a new row in table, once every week.

rsharma21

New Member
Joined
Aug 12, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
1628760701682.png


The Approved and Rejected values (calculated using formulas), are to be noted at the end of every week (or every Monday morning) into the table below it. How can it be done automatically? Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Place the code below in the "ThisWorkbook" module of the VBE. Everytime the workbook is opened it will check to see if the current week number has a value. If it does not it will fill in the current values from D1 and D2. If it does contain a value, it won't do anything.

VBA Code:
Private Sub Workbook_Open()
    Dim curWk As String
    Dim lRow As Long
    Dim ws As Worksheet
 
    Set ws = ActiveSheet 'Alternatively if you have more than one worksheet you can use Thisworkbook.Worksheets("your sheet name")
 
    lRow = Cells(Rows.Count, 2).End(xlUp).Row
 
    curWk = WorksheetFunction.WeekNum(Now())

    With Cells(lRow, 2)
        If Mid(.Offset(1, -1).Value, 2, 3) = curWk Then
            .Offset(1, 0).Value = Cells(1, 4).Value
            .Offset(1, 1).Value = Cells(2, 4).Value
        End If
    End With
End Sub
 
Last edited:
Upvote 0
Solution
@Crystalyzer Thanks alot for the help!!!
Maybe it is too much to ask for, but do you think this can be achieved without VBE? I can't seem to think of a logic to make it work that way.
 
Upvote 0
Any formula wouldn't be static and the value would change unless you copied them and pasted values manually
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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