# Formula or VBA for excel to auto target 7 days of data of past week

#### determinedtoexceed

##### New Member
Dear Sirs

Is there a way for excel functions or VBA to automatically target "the 7 dates of last week" and calculate the 7 days average , and taking this data to shown on for example cell AAA9?

Book1
ABCDEFGHIJKLMNOPQRSTUVWX
1
2MonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSat
3Item 2019/11/182019/11/192019/11/202019/11/212019/11/222019/11/232019/11/242019/11/252019/11/262019/11/272019/11/282019/11/292019/11/30Nov. FCSTNov. Actual vs FCSTNov. sales order issued2019/12/12019/12/22019/12/32019/12/42019/12/52019/12/62019/12/7
40006TW-816-641-524-714-611-680-962-816-642-666-855-92316360102.74%-16808-8-1062-1370
50036TW-486-452-325-362-358-56-1-549-502-424-465-450-6098601129.39%-11129-723-1080
60049TW-188-141-125-132-147-170-175-199-161-134-170-2063152114.28%-3602-194-330
Sheet1

[/QUOTE]

### Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

#### Rijnsent

##### Well-known Member
Hi there,
I'd go for a =AVERAGEIFS formula, where you have two conditions, something in this direction:
AAA9: =AVERAGEIFS (A9:ZZ9,A\$3:ZZ\$3,">="&DATE(2019,12,12),A\$3:ZZ\$3,"<="&DATE(2019,12,19))
Cheers,
Koen

#### determinedtoexceed

##### New Member
Hi there,
I'd go for a =AVERAGEIFS formula, where you have two conditions, something in this direction:
AAA9: =AVERAGEIFS (A9:ZZ9,A\$3:ZZ\$3,">="&DATE(2019,12,12),A\$3:ZZ\$3,"<="&DATE(2019,12,19))
Cheers,
Koen
Hi Rijin,

thank you, but is there a way without manually input =DATE(*,*), which the system can automatically recognize "when was past week"

#### Rijnsent

##### Well-known Member
Try TODAY() and TODAY()-7... Or you'd have to come up with with a fancier "past week" definition, could e.g. be =TODAY()-WEEKDAY(TODAY(),2) -> this will always give you last sunday.
Cheers,
Koen

Replies
6
Views
198
Replies
1
Views
194
Replies
6
Views
177
Replies
3
Views
547
Replies
1
Views
307

1,129,847
Messages
5,638,690
Members
417,043
Latest member
paul43

### 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.

### Which adblocker are you using?

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

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