Date Issue Between Users

JBDB

New Member
Joined
Apr 3, 2023
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I have a piece of VBA (see in full below) that processes data from one sheet and outputs into another. Both spreadsheets are stored in a SharePoint site.

The code works absolutely fine on my PC and one member of the team who run it.
However, on the other 2 team members PCs an error occurs.

There are dates in column E that come into the sheet with "." separators (not "/" or "-"), but these are corrected earlier in the code and I don't believe the issue lies here.

weekly sheet bug.png

Using the message boxes added above (marked in red) I figured out the issue.
I believe the issue is occurring in the highlighted Arr(i,5) > DateAdd ("d", 6 , CDate(SatWkStart))).
The code (on the 2 specific users PCs) states for example that:
  • the 29th of March is not greater than the 25th March nor is it less than the 31st March
Which is of course, incorrect.
However it works fine on my PC and the other user in the team.

Any ideas? Is there a date setting somewhere?

Full Code:
VBA Code:
Option Explicit

Sub Create_Timesheet_Old()
Dim i As Long, j As Long, i2 As Long, Ctr As Long, LastRow As Long, Ctr2 As Long
Dim EmpCode As String
Dim Arr As Variant
Dim FileName As String
Dim NewTS As Workbook, Master As Workbook
Dim SatWkStart As String
Dim ContractNo As String, Remarks As String
Dim CNCtr As Long, CNColRef As Long
Dim NewCN As Boolean
Dim Continue As Boolean
Dim x1 As Single, x15 As Single
Dim iError As Long
Const SaveFolder As String = "XX-SHAREPOINT-LOCATION-XX"

Call TurnStuffOff
Set Master = ThisWorkbook

'check for '.' in dates
If InStr(1, Master.Sheets("Import").Cells(2, 5), ".") = 0 Then
    MsgBox "Please insert new data, this has already been processed" & Chr(13) & "If this issue persists, please contact XX-MY EMAIL-XX"
    Call TurnStuffOn
    Exit Sub
End If

'sort out date col
Arr = Master.Sheets("Import").Range("A1").CurrentRegion
For i = 2 To UBound(Arr, 1)
    Master.Sheets("Import").Cells(i, 5) = Replace(Master.Sheets("Import").Cells(i, 5), ".", "/")
Next i

Master.Sheets("Import").Activate
Master.Sheets("Import").Range("A1").CurrentRegion.Sort Key1:=Range("B1"), Order1:=xlAscending, Key2:=Range("E1"), Order2:=xlAscending, Key3:=Range("C1"), Order3:=xlAscending, Header:=xlYes

Arr = Master.Sheets("Import").Range("A1").CurrentRegion

'reset error message
For i = 9 To 30
    For j = 2 To 4
        Master.Sheets("Home").Cells(i, j) = ""
    Next j
Next i
iError = 9

For i = 2 To UBound(Arr, 1)
    EmpCode = Arr(i, 1)
    
    'get saturday of week
    SatWkStart = CDate(Arr(i, 5))
    Do Until Weekday(CDate(SatWkStart), vbMonday) = 6
        SatWkStart = DateAdd("d", -1, SatWkStart)
    Loop
    
    FileName = Replace(SatWkStart, "/", "-")
    
    'create weekly TS
    Set NewTS = Workbooks.Add
    Application.DisplayAlerts = False
    Master.Sheets("Timesheet").Copy After:=NewTS.Sheets(1)
    NewTS.Sheets(1).Delete
    Application.DisplayAlerts = True
    
    'fill in headers
    NewTS.Sheets(1).Cells(2, 3) = Arr(i, 2) 'name
    NewTS.Sheets(1).Cells(2, 7) = DateAdd("d", 6, CDate(SatWkStart)) 'week end friday
    NewTS.Sheets(1).Cells(2, 13) = EmpCode 'ID
    
    'get end of employee
    i2 = i
    Do Until Arr(i2, 1) <> EmpCode Or i2 = UBound(Arr, 1)
        i2 = i2 + 1
    Loop
    If i2 <> UBound(Arr, 1) Then
        LastRow = i2 - 1
    Else
        LastRow = i2
    End If
    
    CNCtr = 0
    
    'for Sat-Fri
    For Ctr = 0 To 6
        Remarks = ""
        'run through whole section and record line by line
        For i2 = i To LastRow
            If CDate(Arr(i2, 5)) = DateAdd("d", Ctr, CDate(SatWkStart)) Then
            
                If Arr(i2, 3) = Arr(i2, 4) Then
                    If UCase(Arr(i2, 3)) = "SICK" Then
                        ContractNo = "S"
                    ElseIf UCase(Arr(i2, 3)) = "HOLIDAY" Then
                        ContractNo = "H"
                    ElseIf UCase(Arr(i2, 3)) = "ABSENT" Then
                        ContractNo = "UA"
                    Else
                        ContractNo = "AA"
                    End If
                Else
                    ContractNo = Arr(i2, 3)
                End If
                
                NewCN = True
                'check if contract no already there
                For Ctr2 = 1 To 6
                    If NewTS.Sheets(1).Cells(4, 2 + (Ctr2 * 2)) = ContractNo Then
                        NewCN = False
                        CNColRef = Ctr2
                    End If
                Next Ctr2
                If NewCN = True Then
                    CNCtr = CNCtr + 1
                    CNColRef = CNCtr
                End If
                x1 = 0
                x15 = 0
                
                If CNCtr > 6 Then
                    'record 7+ contracts error
                    Master.Sheets("Home").Cells(iError, 2) = EmpCode
                    Master.Sheets("Home").Cells(iError, 3) = SatWkStart
                    Master.Sheets("Home").Cells(iError, 2) = ContractNo & " not recorded within timesheet due to there being 6+ codes this week."
                    iError = iError + 1
                Else
                    If NewCN = True Then
                        NewTS.Sheets(1).Cells(4, 2 + (CNColRef * 2)) = ContractNo
                    End If
                    'for each allocated to that contract
                    Continue = True
                    Do Until Continue = False
                        'record hours and rate: night 1.5, w/e 1.5 all else 1.0 unless remarked
                        If Ctr = 0 Or Ctr = 1 Then
                            x15 = x15 + Arr(i2, 6) + Arr(i2, 7)
                        Else
                            x1 = x1 + Arr(i2, 6)
                            x15 = x15 + Arr(i2, 7)
                        End If
                        'record remarks (col I)
                        If Arr(i2, 9) <> "" Then
                            Remarks = Remarks & Arr(i2, 9) & ", "
                        End If
                        
                        i2 = i2 + 1
                        If i2 = LastRow + 1 Then
                            Continue = False
                        ElseIf Arr(i2, 3) <> ContractNo Or CDate(Arr(i2, 5)) <> DateAdd("d", Ctr, CDate(SatWkStart)) Then
                            Continue = False
                        End If
                    Loop
                    
                    'input hours
                    If x1 > 0 Then
                        If x15 > 0 Then
                            NewTS.Sheets(1).Cells(6 + (Ctr * 2), 2 + (CNColRef * 2)) = x1
                            NewTS.Sheets(1).Cells(6 + (Ctr * 2), 2 + (CNColRef * 2) + 1) = 1
                            NewTS.Sheets(1).Cells(6 + (Ctr * 2) + 1, 2 + (CNColRef * 2)) = x15
                            NewTS.Sheets(1).Cells(6 + (Ctr * 2) + 1, 2 + (CNColRef * 2 + 1)) = 1.5
                        Else
                            NewTS.Sheets(1).Cells(6 + (Ctr * 2), 2 + (CNColRef * 2)) = x1
                            NewTS.Sheets(1).Cells(6 + (Ctr * 2), 2 + (CNColRef * 2) + 1) = 1
                        End If
                    ElseIf x15 > 0 Then
                        NewTS.Sheets(1).Cells(6 + (Ctr * 2), 2 + (CNColRef * 2)) = x15
                        NewTS.Sheets(1).Cells(6 + (Ctr * 2), 2 + (CNColRef * 2) + 1) = 1.5
                    End If
                    i2 = i2 - 1
                End If
            End If
        Next i2
        
        'enter remarks
        If Remarks <> "" Then
            NewTS.Sheets(1).Cells(6 + (Ctr * 2), 3) = Left(Remarks, Len(Remarks) - 1)
        End If
        
    Next Ctr
    
    NewTS.SaveAs (SaveFolder & EmpCode & " " & FileName & ".xlsx")
    NewTS.Close
    i = i2 - 1
Next i

Call TurnStuffOn

Master.Sheets("Home").Activate
MsgBox "Success"

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
CDate uses your regional settings to convert text to dates. If your regional settings are different, that could cause issues - especially if you are manipulating the input values as text previously. I can't see the code from your image in your posted full code though.
 
Upvote 0
And how can I update the 2 "problem" users?

Apologies, I posted the wrong piece of code in there:
VBA Code:
Option Explicit

Sub Payroll()
Dim NumHelper As Single
Dim i As Long, j As Long, i2 As Long, Ctr As Long, LastRow As Long, Ctr2 As Long, iPers As Long
Dim EmpCode As String
Dim Arr As Variant
Dim FileName As String
Dim Subject As Workbook, Master As Workbook
Dim SatWkStart As String
Dim ContractNo As String, Remarks As String
Dim CNCtr As Long, CNColRef As Long
Dim NewCN As Boolean
Dim Continue As Boolean
Dim x1 As Single, x15 As Single, x2 As Single, xPhone As String, x1Hours As Single
Dim iError As Long
Const SaveFolder As String = "XX-SHAREPOINT-LOCATION-XX"
Const TemplateFolder As String = "XX-SHAREPOINT-LOCATION-XX"
Dim BonusFound As Boolean, ErrCtr As Long, IDref As Long, ContractRef As Long
Dim ArrID As Variant, ArrContract As Variant

Call TurnStuffOff
Set Master = ThisWorkbook

BonusFound = False
ErrCtr = 0

ArrID = Master.Sheets("ID").Range("A1").CurrentRegion
ArrContract = Master.Sheets("Contracts").Range("A1").CurrentRegion
IDref = UBound(ArrID, 1)
ContractRef = UBound(ArrContract, 1)

'check for missing Oracle ID
For i = 2 To UBound(ArrID, 1)
    If ArrID(i, 1) = "" Then
    MsgBox "There are users without Oracle IDs in the ID Tab, please input these." & Chr(13) & "If this issue persists, please contact XX-MY EMAIL-XX"
    Call TurnStuffOn
    Exit Sub
    End If
Next i

'check for missing Oracle contract
For i = 2 To UBound(ArrContract, 1)
    If ArrContract(i, 1) = "" Then
    MsgBox "There are contracts without Oracle Numbers in the Contracts Tab, please input these." & Chr(13) & "If this issue persists, please contact XX-MY EMAIL-XX"
    Call TurnStuffOn
    Exit Sub
    End If
Next i

'check for '.' in dates
If InStr(1, Master.Sheets("Import").Cells(2, 5), ".") = 0 Then
    MsgBox "Please insert new data, this has already been processed." & Chr(13) & "If this issue persists, please contact XX-MY EMAIL-XX"
    Call TurnStuffOn
    Exit Sub
End If

'sort out date col
Arr = Master.Sheets("Import").Range("A1").CurrentRegion
For i = 2 To UBound(Arr, 1)
    Master.Sheets("Import").Cells(i, 5) = Replace(Master.Sheets("Import").Cells(i, 5), ".", "/")
Next i

Master.Sheets("Import").Cells(1, 12) = "Prd Bonus"
Master.Sheets("Import").Cells(1, 13) = "1.0 Total"
Master.Sheets("Import").Cells(1, 14) = "1.5 Total"
Master.Sheets("Import").Cells(1, 15) = "2.0 Total"
Master.Sheets("Import").Cells(1, 16) = "Travel" 'travel payment (21.12)

'reset error message
For i = 9 To 30
    For j = 2 To 4
        Master.Sheets("Home").Cells(i, j) = ""
    Next j
Next i
iError = 9

Master.Sheets("Import").Activate
Master.Sheets("Import").Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("C1"), Order2:=xlAscending, Key3:=Range("E1"), Order3:=xlAscending, Header:=xlYes
Arr = Master.Sheets("Import").Range("A1").CurrentRegion

'replace Oracle ID where found, add when not
For i = 2 To UBound(Arr, 1)
    EmpCode = Arr(i, 1)
    iPers = i
    x1 = 0
    x15 = 0
    x2 = 0
    
    'get end of employee
    i2 = i
    Do Until Arr(i2, 1) <> EmpCode Or i2 = UBound(Arr, 1)
        'total for col M-O
        x1 = x1 + Arr(i2, 6)
        x15 = x15 + Arr(i2, 7)
        x2 = x2 + Arr(i2, 8)
        i2 = i2 + 1
    Loop
    If i2 <> UBound(Arr, 1) Then
        LastRow = i2 - 1
    Else
        LastRow = i2
    End If
    
    'add totals
    Master.Sheets("Import").Cells(i, 13) = x1
    Master.Sheets("Import").Cells(i, 14) = x15
    Master.Sheets("Import").Cells(i, 15) = x2
    
    If InStr(Len(EmpCode) - 1, EmpCode, ".") > 0 Then
        EmpCode = Left(EmpCode, Len(EmpCode) - 1)
    End If
    
    If EmpCode Like "#####" Then
        For Ctr = iPers To LastRow
            Master.Sheets("Import").Cells(Ctr, 1) = "10" & EmpCode
        Next Ctr
    Else
        Continue = False
        i2 = 1
        Do Until Continue = True
            i2 = i2 + 1
            If ArrID(i2, 2) = EmpCode Or ArrID(i2, 1) = EmpCode Then
                For Ctr = iPers To LastRow
                    Master.Sheets("Import").Cells(Ctr, 1) = ArrID(i2, 1)
                    If ArrID(i2, 5) > 0 Then
                        Master.Sheets("Import").Cells(Ctr, 12) = ArrID(i2, 5)
                    End If
                    'travel payment (21.12)
                    If ArrID(i2, 6) > 0 And (Arr(Ctr, 6) + Arr(Ctr, 7) + Arr(Ctr, 8)) Then
                        Master.Sheets("Import").Cells(Ctr, 16) = ArrID(i2, 6)
                    End If
                Next Ctr
                Continue = True
            ElseIf i2 = UBound(ArrID, 1) Then
                ErrCtr = ErrCtr + 1
                IDref = IDref + 1
                Master.Sheets("Home").Cells(ErrCtr + 8, 2) = EmpCode
                Master.Sheets("Home").Cells(ErrCtr + 8, 3) = "No Oracle ID found, please input Oracle ID against " & EmpCode & " now found in row " & IDref & " in the ID tab"
                Master.Sheets("ID").Cells(IDref, 4) = Split(Arr(i, 2), " ")(1)
                Master.Sheets("ID").Cells(IDref, 3) = Split(Arr(i, 2), " ")(0)
                Master.Sheets("ID").Cells(IDref, 2) = EmpCode
                Continue = True
            End If
        Loop
    End If
    i = LastRow
Next i

Master.Sheets("Import").Activate
Master.Sheets("Import").Range("A1").CurrentRegion.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlYes

Arr = Master.Sheets("Import").Range("A1").CurrentRegion

'sort contract numbers
For i = 2 To UBound(Arr, 1)
    ContractNo = Arr(i, 3)
    iPers = i
    
    'get end of contract
    i2 = i
    Do Until Arr(i2, 3) <> ContractNo Or i2 = UBound(Arr, 1)
        i2 = i2 + 1
    Loop
    If i2 <> UBound(Arr, 1) Then
        LastRow = i2 - 1
    Else
        LastRow = i2
    End If
    
    Continue = False
    i2 = 1
    Do Until Continue = True
        i2 = i2 + 1
        If Arr(iPers, 3) = Arr(iPers, 4) Then
            Continue = True
        ElseIf ArrContract(i2, 2) = ContractNo Then
            For Ctr = iPers To LastRow
                Master.Sheets("Import").Cells(Ctr, 3) = ArrContract(i2, 1)
            Next Ctr
            Continue = True
        ElseIf i2 = UBound(ArrContract, 1) Then
            ErrCtr = ErrCtr + 1
            ContractRef = ContractRef + 1
            Master.Sheets("Home").Cells(ErrCtr + 8, 2) = ContractNo
            Master.Sheets("Home").Cells(ErrCtr + 8, 3) = "No Oracle Project found, please input Oracle Number against " & ContractNo & " now found in row " & ContractRef & " in the Contracts tab"
            Master.Sheets("Contracts").Cells(ContractRef, 2) = ContractNo
            Continue = True
        End If
    Loop
    i = LastRow
Next i

Master.Sheets("Import").Activate
Master.Sheets("Import").Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Key3:=Range("C1"), Order2:=xlAscending, Key2:=Range("E1"), Order3:=xlAscending, Header:=xlYes 'travel payment 02.02

Arr = Master.Sheets("Import").Range("A1").CurrentRegion

Dim CurDate As String
Dim HoursTot As Single, HoursPay As Single
Dim iStart As Long, iFin As Long
Dim TravelPayment As Single 'travel payment (21.12)

'sort travel payment (02.02.23)
For i = 2 To UBound(Arr, 1)
    If Arr(i, 16) > 0 Then
        If Arr(i, 3) = "Holiday" Or Arr(i, 3) = "Absent" Then
            Master.Sheets("Import").Cells(Ctr, 16) = ""
        Else
            TravelPayment = Arr(i, 16)
            CurDate = Arr(i, 5)
            iStart = i
            Do Until Arr(i, 5) <> CurDate
                HoursTot = HoursTot + Arr(i, 6) + Arr(i, 7) + Arr(i, 8)
                i = i + 1
            Loop
            i = i - 1
            iFin = i
            
            HoursPay = TravelPayment / HoursTot
            HoursTot = 0
            
            For Ctr = iStart To iFin
                Master.Sheets("Import").Cells(Ctr, 16) = HoursPay * (Arr(Ctr, 6) + Arr(Ctr, 7) + Arr(Ctr, 8))
            Next Ctr
            
        End If
    End If
Next i
TravelPayment = 0

Master.Sheets("Import").Activate
Master.Sheets("Import").Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("C1"), Order2:=xlAscending, Key3:=Range("E1"), Order3:=xlAscending, Header:=xlYes
Arr = Master.Sheets("Import").Range("A1").CurrentRegion
Master.Sheets("Home").Activate

'Payroll - into MGS TS
Dim SatHelper As String, iTS As Long
Dim SatFileName As String
Dim JobList As String, JobHelper As String
Dim JobAlready As Boolean
Dim JobCt As Long
Dim Hours As Single
Dim xPhoneCtr As Long
Dim xPdct As Single, xPdctRate As Single

SatWkStart = CDate(Arr(4, 5))
Do Until Weekday(CDate(SatWkStart), vbMonday) = 6
    SatWkStart = DateAdd("d", -1, SatWkStart)
Loop
SatFileName = Replace(DateAdd("d", 6, CDate(SatWkStart)), "/", "-")

'check for out of range
For i = 2 To UBound(Arr, 1)
    If Arr(i, 5) < CDate(SatWkStart) Or Arr(i, 5) > DateAdd("d", 6, CDate(SatWkStart)) Then
        ErrCtr = ErrCtr + 1
        Master.Sheets("Home").Cells(ErrCtr + 8, 2) = Arr(i, 1)
        Master.Sheets("Home").Cells(ErrCtr + 8, 3) = "Date correction out of week range found, please see row " & i & " in the import tab for details"
    End If
Next i
    
Set Subject = Workbooks.Open(TemplateFolder & "DBL MGS Template.xlsm")
Subject.SaveAs (SaveFolder & SatFileName & " Timesheet.xlsm")
iTS = 9

Subject.Sheets("Timesheet").Cells(2, 4) = DateAdd("d", 6, CDate(SatWkStart))
Subject.Sheets("Timesheet").Cells(2, 7) = "DBL"
iTS = 8
xPhoneCtr = 0

For i = 2 To UBound(Arr, 1)
    EmpCode = Arr(i, 1)
    Hours = 40
    If Arr(i, 12) > 0 Then
        xPdctRate = Arr(i, 12)
    Else
        xPdctRate = 0
    End If
    
    'get end of employee
    i2 = i
    Do Until Arr(i2, 1) <> EmpCode Or i2 = UBound(Arr, 1)
        i2 = i2 + 1
    Loop
    If i2 <> UBound(Arr, 1) Then
        LastRow = i2 - 1
    Else
        LastRow = i2
    End If
    
    'record contract numbers in sheet
    JobList = ""
    JobCt = 0
    For i2 = i To LastRow
        ContractNo = Arr(i2, 3)
                    
        JobHelper = JobList
        JobAlready = False
        Do Until JobHelper = "" Or JobAlready = True
            If ContractNo = Left(JobHelper, InStr(1, JobHelper, ";") - 1) Then
                JobAlready = True
            End If
            JobHelper = Right(JobHelper, Len(JobHelper) - InStr(1, JobHelper, ";"))
        Loop
        
        If JobAlready = False Then
            JobList = JobList & ContractNo & ";"
            JobCt = JobCt + 1
        End If
        
        Do Until Arr(i2, 3) <> ContractNo Or i2 = LastRow + 1 Or i2 = UBound(Arr, 1)
            i2 = i2 + 1
        Loop
        If i2 > LastRow Then
            i2 = LastRow
        ElseIf i2 < UBound(Arr, 1) Then
            i2 = i2 - 1
        End If
    Next i2
    
    JobHelper = JobList
    Do Until JobHelper = ""
        Remarks = ""
        xPhone = ""
        x1Hours = 0
        xPdct = 0
        TravelPayment = 0
        ContractNo = Left(JobHelper, InStr(1, JobHelper, ";") - 1)
        iTS = iTS + 1
        
        For Ctr = 0 To 6
            x1 = 0
            x15 = 0
            x2 = 0
            Remarks = ""
            
            'run through whole section and record line by line
            For i2 = i To LastRow
                If CDate(Arr(i2, 5)) = DateAdd("d", Ctr, CDate(SatWkStart)) And Arr(i2, 3) = ContractNo Then
                    x1 = x1 + Arr(i2, 6)
                    x1Hours = x1Hours + Arr(i2, 6)
                    x15 = x15 + Arr(i2, 7)
                    x2 = x2 + Arr(i2, 8)
                    TravelPayment = TravelPayment + Arr(i2, 16)
                    If Arr(i2, 9) <> "" Then
                        xPhone = xPhone & Arr(i2, 9) & "; "
                    End If
    
                    'record remarks
                    If Arr(i2, 11) <> "" Then
                        Remarks = Remarks & Arr(i2, 11) & ", "
                    End If
                End If
            Next i2

            If x1 > 0 Then
                Subject.Sheets("Timesheet").Cells(iTS, 8 + (12 * Ctr)) = x1
            End If
            If x15 > 0 Then
                Subject.Sheets("Timesheet").Cells(iTS, 13 + (12 * Ctr)) = x15
            End If
            If x2 > 0 Then
                Subject.Sheets("Timesheet").Cells(iTS, 15 + (12 * Ctr)) = x2
            End If
            If Remarks <> "" Then
                Subject.Sheets("Timesheet").Cells(iTS, 16 + (12 * Ctr)) = Left(Remarks, Len(Remarks) - 2)
            End If
            If xPdctRate > 0 Then
                xPdct = xPdct + x1 + x15 + x2
            End If
            
        Next Ctr
        
        'input name, ID and contract number
        Subject.Sheets("Timesheet").Cells(iTS, 2) = Arr(i, 1)
        Subject.Sheets("Timesheet").Cells(iTS, 4) = Left(Arr(i, 2), InStr(1, Arr(i, 2), " ") - 1)
        Subject.Sheets("Timesheet").Cells(iTS, 3) = Right(Arr(i, 2), Len(Arr(i, 2)) - InStr(1, Arr(i, 2), " "))
        If UCase(ContractNo) = "HOLIDAY" Or UCase(ContractNo) = "TRAINING" Then
            Subject.Sheets("Timesheet").Cells(iTS, 7) = 2117132
        Else
            Subject.Sheets("Timesheet").Cells(iTS, 6) = ContractNo
        End If
        
        'phone payment
        If xPhone <> "" Then
            Subject.Sheets("Timesheet").Cells(iTS, 103) = Left(xPhone, Len(xPhone) - 2)
            xPhoneCtr = xPhoneCtr + 1
        End If
        
        'add all pink columns into DR
        Subject.Sheets("Timesheet").Cells(iTS, 122) = x1Hours
        
        'Productivity Bonus
        If xPdctRate > 0 Then
            Subject.Sheets("Timesheet").Cells(iTS, 115) = Round(xPdct * xPdctRate, 2)
        End If
        
        'Travel Payment (into DS) | travel payment (21.12, update 30.01)
        If TravelPayment > 0 Then
            Subject.Sheets("Timesheet").Cells(iTS, 123) = Round(TravelPayment, 2)
        End If
            
        JobHelper = Right(JobHelper, Len(JobHelper) - InStr(1, JobHelper, ";"))
    Loop
    
    i = i2 - 1
Next i

Call TurnStuffOn

If ErrCtr > 0 And xPhoneCtr > 0 Then
    MsgBox "Success, please find timesheet in the SharePoint site." & Chr(13) & "Please correct errors summarised in the home tab." & Chr(13) & "Please input bonuses found in col CY of the timesheet."
ElseIf xPhone <> "" Then
    MsgBox "Success, please find timesheet in the SharePoint site." & Chr(13) & "Please input bonuses found in col CY of the timesheet."
ElseIf ErrCtr > 0 Then
    MsgBox "Success, please find timesheet in the SharePoint site." & Chr(13) & "Please correct errors summarised in the home tab."
Else
    MsgBox "Success, please find timesheet in the SharePoint site."
End If

End Sub
 
Upvote 0
You shouldn't change their regional settings (unless they want you to, since it will affect everything they do), you should alter your code. ;)

Are the dates that come in with full stop separators stored as text, or as actual dates?
 
Upvote 0
@RoryA more future proof that way too! Though they are happy for me to adjust them FYI

They come in as text and after processing looks like they're a mix of "General" and date
Screenshot 2023-04-03 132825.png
 
Upvote 0
How does that selected cell appear in the formula bar? Using Replace to convert the dates with full stops will actually alter some dates unless your dates with the full stops come in in mm.dd.yyyy format. So for example if you get 01.03.2023 that will be converted to 3rd Jan 2023 not 1st March.
 
Last edited:
Upvote 0
Looks fine in the formula bar, as follows.

Numbers are stored as "general":
1680680150973.png


Dates are stored as dates with a custom format:
1680680169743.png


1680680176521.png


Seems odd to me that it works fine on 50% of the machines in the team!
Any ideas?
 
Upvote 0
Just noticed you have declared SatWkStart as a string rather than a date. That could well be your problem.
 
Upvote 0
@RoryA just gave that a go and that simply causes all users (4/4) to have the issue
 
Upvote 0
What exactly did you do?
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,673
Members
449,178
Latest member
Emilou

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