Total and Avg. data from another worksheet based on day of week
Closed
mikeexcelscrub
Posts
1
Registration date
Monday June 16, 2014
Status
Member
Last seen
June 16, 2014
-
Jun 16, 2014 at 02:49 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Jun 17, 2014 at 11:31 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Jun 17, 2014 at 11:31 AM
Related:
- Total and Avg. data from another worksheet based on day of week
- Transfer data from one excel worksheet to another automatically - Guide
- Avg free download - Download - Antivirus
- Total video converter - Download - Video converters
- Time of day clock stopped - Guide
- Windows calendar show week number - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Contributor
Last seen
December 27, 2022
555
Jun 17, 2014 at 11:31 AM
Jun 17, 2014 at 11:31 AM
Hi Mike,
1) adding values based on day of the week.
* Select the cell you want to put the result in, run the code below.
* The code will ask you to input the day of the week.
* The code will give you the opportunity to cancel in case you forgot to select the correct destination cell.
Here is the code:
2) Obtaining average.
Use formula for that (assuming you placed result in A1 of sheet2):
=Sheet2!A1/COUNTIF(B2:B32,"MON")
Best regards,
Trowa
1) adding values based on day of the week.
* Select the cell you want to put the result in, run the code below.
* The code will ask you to input the day of the week.
* The code will give you the opportunity to cancel in case you forgot to select the correct destination cell.
Here is the code:
Sub RunMe()
Dim lCol, MyCol As Integer
Dim lRow, Result As Long
Dim sValue As String
Dim Check As Variant
sValue = InputBox("For which day would you like to add the activities?:")
Sheets("Sheet1").Select
lRow = Range("B1").End(xlDown).Row
For Each cell In Range("B2:B" & lRow)
If cell.Value = sValue Then
lCol = Cells(cell.Row, Columns.Count).End(xlToLeft).Column
MyCol = 2
Do
MyCol = MyCol + 1
Result = Result + Cells(cell.Row, MyCol).Value
Loop Until lCol = MyCol
End If
Next cell
Check = MsgBox("The result will be placed in the active cell.", vbOKCancel)
If Check = vbCancel Then Exit Sub
ActiveCell = Result
End Sub
2) Obtaining average.
Use formula for that (assuming you placed result in A1 of sheet2):
=Sheet2!A1/COUNTIF(B2:B32,"MON")
Best regards,
Trowa