VBA Macro To Sum By Number For Corresponding Week
Nov 26, 2008
I am interested in modifying the below code so that instead of a text output of "Assignment A (20), Assignment B (5)" it would output only the sum of the numbers "25" for the corresponding week. I believe that this will be more clear with an example, so I'm attaching a small sample which shows what my current output is and what I'd like it to be.
Private Sub RestructureHrs()
'Start of Restructure
Dim l As Long ' loop through rows
Dim m As Long 'loop through rows to find last occurrance of person
Dim lLastRow As Long
Dim sPerson As String
Dim sOffice As String
Dim j As Long 'loop through person
Dim k As Long 'loop through weeks
Dim sOutput As String
Dim sOutputPerPerson As String
Dim lNextRow As Long
lLastRow = Range("A" & Rows.Count).End(xlUp).Row
lNextRow = 2
For l = 2 To lLastRow
sPerson = Range("B" & l).Value
sOffice = Range("A" & l).Value
sOutputPerPerson = ""......................
View 4 Replies
ADVERTISEMENT
Mar 6, 2010
I have a running time sheet daily. It has 2 columns for Labor and 2 columns for travel
i.e. travel From / To 1300-1400 calculate 1 hour then travel home 1600-1700 1 hour this is calculated by the date entry 01/02/10 I have another calculation that tracks by the date i.e. 01/02/10 then Next job which all works fine.
The problem becomes how do I calculate a weekly total labor and travel by the date So added another column called weekly hour’s labor and use the Weeknum to determine which week is which day/date so the first Monday in January 2010 is week 2
2 problems
Having many multiple day / date entries are the same date x 7 days Monday –Sunday
(Relies on the date entered and the weeknum) 01/03/10 each line is complete however the dates carry over as does the time
When trying to calculate each row x 3 same date time then the value will be incorrect I need to calculate
Say 9.5 hour labor from the date 01/03/10 not 28.5 hours and then calculate the total weekly hours
01/03/10, 9.5 hours labor, 3 hours travel
01/03/10, 9.5 hours labor, 3 hours travel
01/03/10, 9.5 hours labor, 3 hours travel
i do have work and travel times for each job on the same line (separate columns) but I display the total here by date to summarize the totals
i have tried sum products and sumif to avail. I am using Windows XP SP2 with MS Office 2007
how do i calculate weekly hours by date and weeknum ?
Total Work per day
Total Travel per day
Daily....................
View 9 Replies
View Related
Jan 8, 2010
What im trying to do is have a macro that will open a file called Blue 1.xls in location "I:SchedulesBlue" and then copy data from cells N13:034. Then paste it into another excel file (Press.xls)on worksheet "Press Break" cell G14.
The data that is copied not always fills up the cells N13:O34 so I need it to go to the next blank cell in column N and paste the information from file Blue 2, and so on for Yellow 1, Yellow 2, YellNR, and Green.
So to summarise I need a macro to open 6 files copy data from the same location on each of the files(N13:O34) then close and paste it into a master document(Press.xls) worksheet "Press Break".
View 9 Replies
View Related
Jan 19, 2010
I am new to VBA & not sure of the full understanding of code copied from a workbook which worked on the same principle but with Monthly (12) tabs. I thought if modified to show weeks, the macro would be able to locate the current week tab & day/date within - but upon opening, the cell stops at WK19 & column O - rather than WK43, Column N (which changes daily).
Sub Auto_Open()
week(1) = "WK1"
week(2) = "WK2"
week(3) = "WK3"
week(4) = "WK4"
week(5) = "WK5"
week(6) = "WK6"
week(7) = "WK7"
week(8) = "WK8"
week(9) = "WK9"
week(10) = "WK10"
week(11) = "WK11"
week(12) = "WK12"
week(13) = "WK13"
week(14) = "WK14"
week(15) = "WK15"
week(16) = "WK16"
week(17) = "WK17"
week(18) = "WK18"
week(19) = "WK19"
week(20) = "WK20"
week(21) = "WK21"
week(22) = "WK22"
week(23) = "WK23"
week(24) = "WK24"......................................
View 9 Replies
View Related
Nov 24, 2009
I have a column where I am convering the Date into a Fiscal week number.
For example 10/6/2009 is Work week 41
Now I want to show October Week 41
I need to add the month and the text "Week" before the week number. what is the formula I use.
View 3 Replies
View Related
Jul 10, 2014
I have a spreadsheet for tracking jobs. Most everything is based off of week # rather than date. I am trying to get the stats page of the workbook to tally the total number of late jobs per week.The current week is taken care of because there is a function that automatically displays on time yes or no and I just set it to count the yeses or nos.The problem I am having is for past weeks.
I tried- =COUNTIF(Table2[On-time],"No"+(CountIF(Table2[Week # Hidden],"<Weeknum(Now())" but that doesn't work. I also tried isolating the < like this. =COUNTIF(Table2[On-time],"No"+(CountIF(Table2[Week # Hidden],"<"Weeknum(Now()) and that did not work either.
------ UPDATE
In response to using CountIFS I have also tried-
=COUNTIFS(Table2[On-time],"NO",Table2[Due Week '# Hidden],"<Weeknum(Now())") this just returns a zero value even when I have a late job listed three weeks ago.
View 10 Replies
View Related
Nov 25, 2013
I have in column A the frequency in weeks which I need an inspection to be done.
I have in Column B the last week in which the inspection was done.
I want to produce in column C the next week required to perform inspection.
So lets say:
A B C
26 28 54
If I add the 2 columns I get week 54. Is there any way I can convert that to read week 2?
View 2 Replies
View Related
Sep 15, 2014
I need to calculate and compare the extra number of hours worked less lunch time (0.5h per day) "per day sum by week" and total "per week" :
- number of hours above 40h per week;
- number of hours above 9h per day sum by week;
and keep the higher.
I've nearly found the formula to have extra hours for total week
=SUMPRODUCT(($B$3:$AK$3),--ISNUMBER($B$3:$AK$3),--(WEEKNUM($B$2:$AK$2+0,2)=AN1))-(SUMPRODUCT(--(WEEKNUM($B$2:$AK$2+0,2)=AN1),--ISNUMBER($B$3:$AK$3))*0.5)-40
But for total week I don't know how to sum per week hours above 9+0,5 per day
test extra hour.xlsx
View 6 Replies
View Related
Jun 18, 2009
How can i change week number to start from 1 if my year starts 1/07/2009 if i use function = weeknum() it returns the value 27.
View 7 Replies
View Related
May 4, 2006
as such Excel (2003) is putting in the wrong weeknumbers in my spreadsheet, for example 02/01/2006 is listed as week 0 when in fact it is week 1, how can I get it too correct this problem?
I am using the following formula, could someone explain this formula in
english?
=CONCATENATE(YEAR(BM2),"_","w",IF((WEEKNUM(BM2)-1)<10,CONCATENATE("0",(WEEKNUM(BM2)-1)),(WEEKNUM(BM2)-1)))
View 14 Replies
View Related
Mar 26, 2008
I want to use a formula to calculate what week number in the month it is (i.e 1 to 6) from a particular date.
I know how to calculate this on an annual basis (i.e. 1 to 52) but not within the month.
This is what I have so far...
=IF(OR(D58=1, D58>=D57), ROUNDUP(DAY(D61)/7,0),ROUNDUP(DAY(D61)/7,0)+1)
d58 is a Weeday formula looking at d61 which is the date i want to look at. d57 is the weekday number of the first day of the month in cell d61.
View 13 Replies
View Related
Jul 12, 2006
I have a list of random dates between 09/01/05 and 07/01/06. I would like to assign a week number to each date. For example, I would like it to be week 1 if the date is between the dates of 09/01/05 and 09/07/05. Is there any simple way of going about this?
View 3 Replies
View Related
Sep 5, 2006
I'm using excel 2003 and I searching for a small code to automaticly generate the begin- and end- date of a week (from monday till sunday) the only variable that I wanna give is the Weeknumber. So if I write a weeknumber in cell(a,1). I want the begin-date (monday) in cell (b,1) and I want the end-date (sunday) in cell (c,1).
for example:.....
View 4 Replies
View Related
Feb 15, 2008
Is there a function in Excel we can use identify a certain date to be the week no. ?
For example, 15 Feb 08 is (part of) Week 7 of 2008
View 8 Replies
View Related
Nov 15, 2013
I have week numbers from 1 to 52, now i want to get which week number will falls in which month, is there any formula in excel
for eg. Week 01 - 05 will fall in January month (2014), likewise..
View 1 Replies
View Related
May 4, 2006
I can retrieve the weeknum of any particular date using =WEEKNUM(x) or =TRUNC(((x-DATE(YEAR(x),1,0))+6)/7)
But I'm looking for a UDF to output the tax year week number where the tax year always starts on 6th April. The std weeknum for 6th of april pretty much varies around week 13 but as it varies I don't ever get a strictly true result by deducting 13 from WEEKNUM().
View 4 Replies
View Related
Apr 15, 2012
We have started a new venture from 5th April & I need to create a template for a year and assign week no against the dates. The week1 will start from 5th April & week 52 will end on 31st March.
Also there will be a summary of the Week No(Starting Date & End Date) against each week at the top of the template. I could put the formula for the summary part but I am unable to figure out how to assign week no against the dates as given below. It is very difficult to assign the week no manually for the whole year & also it is vulnerable to error. a formula across B7:B23 which can deliver the desired result?
Sheet2 Â ABC1Week NoStart DateEnd Date2Week15-Apr8-Apr3Week29-Apr15-Apr4Week316-Apr22-Apr5Â Â Â 6DateDesired
Result 75-AprWeek1 86-AprWeek1 97-AprWeek1 108-AprWeek1 119-AprWeek2 1210-AprWeek2 1311-AprWeek2 1412-
AprWeek2Â 1513-AprWeek2Â 1614-AprWeek2Â 1715-AprWeek2Â 1816-AprWeek3Â 1917-AprWeek3Â 2018-AprWeek3Â 2119-
[Code] .........
View 9 Replies
View Related
Jul 31, 2013
I am trying to get a formula that will give me the number of days remaining in the week. I have a formaula for number of days until the end of the month and number of days until the end of the quarter, but just need the week.
So if the formula was run today it would show 4 as the result.
View 9 Replies
View Related
Jun 27, 2014
I am trying to count the number of events by week. My column is title weekof and of it I have made a defined range...weekof. My formula is simple countif(weekof, "2/9/14")
The formula providing the 2/9/14 is =$E2-WEEKDAY($E2)+1
Countif seems not to recognize the date at all. I found a posting showing this to work =COUNTIF(Weekof,"
View 7 Replies
View Related
Oct 14, 2008
We have a fiscal calendar which starts Oct 1. I would like to display the proper week numbers. I worked out a formula which seems to work (except for week 53) but it would be better if I didn't have to rely on other users having the Analysis Toolpak installed. My date is located in '3930!I4' and this is the formula that works with the toolpak: ...
View 9 Replies
View Related
Jul 16, 2006
I am trying to get a sheet to automatically calculate week numbers from a given date (start) and the current date, the problem I am having is I only want to cycle 18 weeks not 52.so weeknum wont work
ie
10 weeks after start date would return Week 10
18 weeks after start date would return Week 18
19 weeks after start date would return Week 1
25 weeks after star date would return Week 6
37 weeks after start date would return Week 1
etc...
View 6 Replies
View Related
Oct 18, 2006
Daily i import sheets into excel and the sheet name is uniformed to the following
20061017_BNKREC - 20061018_BNKREC - 20061019_BNKREC ..........
just for clarity purposes
[2006] = year, [10] = month, [17] = previous day, [_BNKREC] = report type
I'll be creating a graph to which shows account balance by week, by account.
The data will be coming in daily. i know i will need to create either a dynamic range or copy my data into a new sheet. My head is spinning because i need excel to somehow (either in a formula or VB) determine what WorkingWeek the sheet is in. I dont want to have to keep adjusting formulae or ranges when import a new sheet..
bare with me here as its hard to explain ................
View 2 Replies
View Related
Oct 9, 2007
I've done a search on here to find out how to convert a date to a week number & found this: - =WEEKNUM(A1) which works fine, But I also want the result to display the year.
So 08/10/07 becomes WK40-07
I can't see how to do it!
View 5 Replies
View Related
Jan 27, 2008
I'm wanting tocset up a speadsheet that, if I input a week number, it would give me a list of targets for that week. eg.
weektarget 1target 2target 3target 4
1 800 97 1.5 20
and then something differernt for week 2, 3, 4 and so on. I've tried IF, but can only seem to get that to work for 1 cell and I'm wanting 4+.
View 2 Replies
View Related
Jun 24, 2008
In my macro, I have a variable 'logDate' that is a 6 digit date in the format mmddyy
If 'logDate' falls on a Monday then I need to set another variable 'd' to equal 1, if Tuesday then 2 etc.
ie: 'logdate' = 062308 I need to set 'd' =
View 7 Replies
View Related
Aug 3, 2008
Need to write some kind of formula on Excel to count weeks backwards, year start 1 July till 30 june ,
View 8 Replies
View Related
Aug 4, 2014
I want a formula to calculate the average number of staff working per week in the attached data.
View 9 Replies
View Related
Jan 8, 2009
just wondering if its possible to format a cell to display date and week number and if so how to go about it
eg
04/01/09 week 1
View 7 Replies
View Related
Nov 12, 2009
I have a spreadsheet that I use to convert a purchase order ship date from the actual date to the corresponding week it falls out on. The fiscal year always starts on February 1 regardless of the day of the week. The problem i am encountering is when the year changes. As soon as I enter 01/01/2010, the response I get is -4, where as 12/31/2009 is 48.
I am using the following formula that I found somewhere, where R2 = 02/01/2009 (02/01/2009 falls out on a Sunday). =INT((R2-DATE(YEAR(R2),2,1)-WEEKDAY(R2,1))/7)+2. I need to make the formula "not care about" the day of the week.
View 3 Replies
View Related
Jul 19, 2014
I have two processes that has to run depending of the week number of the year. So even weeks has to run "sub 2" and odd weeks has to run "sub 1".
Weeks with number 1,3,5,7,9,11,13,15 etc has to call "sub 1" and weeks 2,4,6,8,10,12,14,16 etc has to call "sub 2".
The filenames consist of "name_name_YYYYMMDD.xls" (example: SteveSmith_Runningshoes_20140719.xls)
So vba needs to calculate the week number by reading the YYYYMMDD of the filename and then call the correct sub.
View 6 Replies
View Related