ASP Free Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherASP Free Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old April 16th, 2008, 10:59 AM
jodie Fox jodie Fox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 jodie Fox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 36 sec
Reputation Power: 0
Angry Excel Rounding up HELP

Hi All

I am new to this site and need major help.

I have a spreadsheet which works out the hours spent on certain projects. I need the Monthly total to work the hours worked into days rounded up to the nearest 1/4 of a day for eg...
Cell A31 = SUM(A4:A31) so I get the total hours worked per month.
Then
Cell A32 =A31/7 (as 7 is the hours worked per day and I will get the monthly total of days used per month)
If I put that I have worked for 2 & 1/2 as 2.50 in a cell it calculates it as 0.31 (I need this to round up to the nearest 1/4 hour!) Is there any way I can do this?

Thaks in advance

Jodie

Reply With Quote
  #2  
Old April 16th, 2008, 11:09 AM
AOG123's Avatar
AOG123 AOG123 is offline
Registered Hero
ASP Free Novice (500 - 999 posts)
 
Join Date: Oct 2006
Posts: 883 AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level)AOG123 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 2 Days 10 h 44 m 58 sec
Reputation Power: 995
Quote:
Originally Posted by jodie Fox
Hi All

I am new to this site and need major help.

I have a spreadsheet which works out the hours spent on certain projects. I need the Monthly total to work the hours worked into days rounded up to the nearest 1/4 of a day for eg...
Cell A31 = SUM(A4:A31) so I get the total hours worked per month.
Then
Cell A32 =A31/7 (as 7 is the hours worked per day and I will get the monthly total of days used per month)
If I put that I have worked for 2 & 1/2 as 2.50 in a cell it calculates it as 0.31 (I need this to round up to the nearest 1/4 hour!) Is there any way I can do this?

Thaks in advance

Jodie


Just to clear this up a little,.. can you type exactly what you'd like the result to be on this example of 7 / 2.5
with 1.75 being a qtr day "in theory"

Reply With Quote
  #3  
Old April 16th, 2008, 11:48 AM
Lauramc's Avatar
Lauramc Lauramc is offline
SQL Slarentice
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2004
Location: In My Happy Place
Posts: 1,782 Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 15 h 42 m 2 sec
Reputation Power: 1081
You can get to tenths of an hour rather easily, but I can find no easy way to get to the closest quarter of an hour. It would require some rather creative and probably imperfect logic to do that.

You could get to tenths of an hour by doing something like this:
Code:
=ROUND((SUM(A4:A31) /7),1)
Where 7 is equal to the number of hours in a day.
__________________
Slarentice (origin:Shadow Wizard of ASP Free) [noun] A slave and apprentice of the Wizard's Circle (specifically of mehere) at ASP Free.
----
If shemzilla takes over, it's best to be on his good side


Reply With Quote
  #4  
Old April 16th, 2008, 01:09 PM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,185 richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 1 Day 12 h 12 m 58 sec
Reputation Power: 1209
Try this.

Go into Visual Basic Editor in Excel (Alt + F11 or Tools...Macro -> Visual Basic Editory) and within your Workbook, Insert a new module (In left hand pane, right click on the VBA Project for your workbook and Select Insert -> Module). In your module, paste :-
Code:
Function get_quarters(ByVal value)
Dim main_value
main_value = value / 7

Dim arr_value
arr_value = Split(main_value, ".")
Dim decimal_value
decimal_value = "0." & arr_value(UBound(arr_value))
whole_value = arr_value(LBound(arr_value))

Select Case decimal_value
Case Is > 0.75
get_quarters = whole_value + 1
Case Is > 0.5
get_quarters = whole_value & ".75"
Case Is > 0.25
get_quarters = whole_value & ".5"
Case Is > 0
get_quarters = whole_value & ".25"
Case Else
get_quarters = whole_value
End Select

End Function

Save your workbook (Ctrl + S)

Go back to your workbook. In cell A32 type:-
Code:
=get_quarters(A31)
Not sure if this is the most efficient way of doing it, but I think it works. Haven't done huge amount of testing with it, but it should round up to the nearest 0.25.

Hope that helps.
__________________
Policy Check

I'd rather have a full bottle in front of me, than a full frontal lobotomy...

Reply With Quote
  #5  
Old April 17th, 2008, 05:35 AM
jodie Fox jodie Fox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 jodie Fox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 36 sec
Reputation Power: 0
Quote:
Originally Posted by AOG123
Just to clear this up a little,.. can you type exactly what you'd like the result to be on this example of 7 / 2.5
with 1.75 being a qtr day "in theory"


Hi

I need the hours to add up first so my soreadsheet is first broken down into weeks (minus weekends) then I have a weekly total which calculates the weekly hours. At the end of each week the total should add up to 28. Then after the last working day of the month I have a monthly figure which is all the hours in a day added to give me the hours per month. I then have a sum which is hours per month divided by hours per day (in theory this should give me a monthly daily total spent on a projecy) I need it to work out if I am only spending 2.5 hours on a project this should round up to the nearest 1/4 day. same if I only spent 1.5 hours on a project it would round down to the full day? Does this make sense?

Thanks
Jodie

Reply With Quote
  #6  
Old April 17th, 2008, 05:37 AM
jodie Fox jodie Fox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 jodie Fox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 36 sec
Reputation Power: 0
Quote:
Originally Posted by richyrich
Try this.

Go into Visual Basic Editor in Excel (Alt + F11 or Tools...Macro -> Visual Basic Editory) and within your Workbook, Insert a new module (In left hand pane, right click on the VBA Project for your workbook and Select Insert -> Module). In your module, paste :-
Code:
Function get_quarters(ByVal value)
Dim main_value
main_value = value / 7

Dim arr_value
arr_value = Split(main_value, ".")
Dim decimal_value
decimal_value = "0." & arr_value(UBound(arr_value))
whole_value = arr_value(LBound(arr_value))

Select Case decimal_value
Case Is > 0.75
get_quarters = whole_value + 1
Case Is > 0.5
get_quarters = whole_value & ".75"
Case Is > 0.25
get_quarters = whole_value & ".5"
Case Is > 0
get_quarters = whole_value & ".25"
Case Else
get_quarters = whole_value
End Select

End Function

Save your workbook (Ctrl + S)

Go back to your workbook. In cell A32 type:-
Code:
=get_quarters(A31)
Not sure if this is the most efficient way of doing it, but I think it works. Haven't done huge amount of testing with it, but it should round up to the nearest 0.25.

Hope that helps.



Hi thanks for this but I keep getting a compile error sub or function not defined. Do you know why this is?

Thanks
Jodie

Reply With Quote
  #7  
Old April 17th, 2008, 06:08 AM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,185 richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 1 Day 12 h 12 m 58 sec
Reputation Power: 1209
I guess it's saying it can't find the function get_quarters.

Did you paste the full function into a Module of the VBAProject for your spreadsheet?

As in the instructions above.

You must also save the spreadsheet before using the function.

Could you post a screenshot of the Visual Basic Editor showing your function?

Reply With Quote
  #8  
Old April 17th, 2008, 06:19 AM
jodie Fox jodie Fox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 jodie Fox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 36 sec
Reputation Power: 0
Function get_quarters(ByVal value)
Dim main_value
main_value = value / 7

Dim arr_value
arr_value = Split(main_value, ".")
Dim decimal_value
decimal_value = "0." & arr_value(UBound(arr_value))
whole_value = arr_value(LBound(arr_value))

Select Case decimal_value
Case Is > 0.75
get_quarters = whole_value + 1
Case Is > 0.5
get_quarters = whole_value & ".75"
Case Is > 0.25
get_quarters = whole_value & ".5"
Case Is > 0
get_quarters = whole_value & ".25"
Case Else
get_quarters = whole_value
End Select

End Function

This is what I have entered. (Sorry couldn't get a screen shot!) The top line is highlighted yellow and the word 'split' is highlighted gray on the 5th line down. Thanks for all your help on this as I am seriously considering launching PC out of nearest window LOL =)

jodie

Reply With Quote
  #9  
Old April 17th, 2008, 06:28 AM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,185 richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110376 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 1 Day 12 h 12 m 58 sec
Reputation Power: 1209
I've attached a test spreadsheet that contains the function.

Unzip the file and then see if the spreadsheet works on your machine.

You'll have to Enable Macros when the warning appears.
Attached Files
File Type: zip test_sheet.zip (6.1 KB, 26 views)

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherASP Free Lounge > Excel Rounding up HELP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |