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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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