Userform report on previous week

kayakginge

New Member
Joined
Dec 11, 2017
Messages
19
Hi,

I am trying to create a userform that will look through a table and display a sum of the data from the previous 7 days in textbox2 and average in textbox3.

i have set it so that textbox1 is automatically populated with todays date but want to be able to allow the user to change the date to any date if needed, click a command button named submit and re display the updated data in textbox2.

is this possible?

i have only made the userform so far and do not know how to procede with the coding so have none to share.

i couldn't find any threads with a similar title but if anybody has any they can point me to instead i would be very grateful.

Many thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
It may help you you supplied additional info, such as what ranges you want summed and what ranges has the dates
 
Upvote 0
this will work when u have the table in sheets(1) and de dates are in column A en the data is in column B.

Code:
With Sheets(1)
       For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row
            If .Cells(i, 1).Value > CDate(TextBox1.Value) - 7 Then
                x = x + .Cells(i, 2).Value
                av = av + 1
            End If
       Next
End With
TextBox2.Value = x
TextBox3.Value = x / av
 
Last edited:
Upvote 0
Thank you so much for the replies.

yes the date will always be in column A and the data in column B. is it possible to use this code for a different table on the same sheet or different sheet?
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

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