amend VBA code to subtract 1 hour from working hours

steve400243

Active Member
Joined
Sep 15, 2016
Messages
429
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello, I use the below VBA code to generate working hours. I need it to subtract 1 hour from the total? Any thoughts?

Code:
Public Sub Worksheet_Change(ByVal Target As Range)


   Dim Cell As Range
   
   ' Calculate working hours if start and finish are both present
   For Each Cell In Target
      If (Cell.Column = [M3].Column Or Cell.Column = [N3].Column) And _
         (IsDate(Cells(Cell.Row, "M")) And IsDate(Cells(Cell.Row, "N"))) Then
         Cells(Cell.Row, "O") = WorkingHours.WorkingHours(Cells(Cell.Row, "M"), Cells(Cell.Row, "N"))
      End If
   Next Cell


End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
What type of value does the WorkingHours function return? If it is just a number just subtract 1 :D

I assume it is more complicated but I have not used that function before. Is that something you made?
 
Upvote 0
Tried that method with no results. it returns a time value - 9:00 This was made for me to calculate working hours between a start and end time. between 8:00 - 5:00 normal work week.
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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