I've been using this forum more times that I can count, this is my first time asking a question here, currently my work makes me use excel and excel vba even for breakfast, so even thought that I'm nowhere near to be called a pro, I've made various rudimentary projects in my time.
This problem is driving my crazy even to the point of despair, just can't see why, Don't know how to highlight the problem happens in the * part *
Function WAGESPERHOUR(TSHOUR As Date, TEHOUR As Date, _
Optional TDAY, Optional TWEEK)
Dim tableWages(10000) As dataSchedule
Dim nSheet As String, inRow As Integer, inCol As Integer, _
weekCol As Integer, dayCol As Integer, dateCol As Integer, _
sShiftCol As Integer, eShiftCol As Integer, hoursWCol As Integer, _
wageTCol As Integer, itemsCount As Integer, n As Integer
Application.Volatile
Erase tableWages
WAGESPERHOUR = 0
nSheet = "input schedule"
inRow = 5
inCol = 1
weekCol = 2
dayCol = 1
dateCol = 3
sShiftCol = 6
eShiftCol = 7
hoursWCol = 10
wageCol = 11
itemsCount = 0
For n = 0 To 9999
If Sheets(nSheet).Cells(inRow + n, dateCol) = "" Then
itemsCount = n - 1
Exit For
End If
tableWages(n).day = Sheets(nSheet).Cells(inRow + n, dayCol)
*****tableWages(n).week = Sheets(nSheet).Cells(inRow + n, weekCol)*****
tableWages(n).startShift = Sheets(nSheet).Cells(inRow + n, sShiftCol)
tableWages(n).endShift = Sheets(nSheet).Cells(inRow + n, eShiftCol)
tableWages(n).hoursWorked = Sheets(nSheet).Cells(inRow + n, hoursWCol)
tableWages(n).wage = (Sheets(nSheet).Cells(inRow + n, wageCol) / 2)
Next
For n = 0 To itemsCount
If TDAY = "" Then
tableWages(n).day = TDAY
End If
If TWEEK = "" Then
tableWages(n).week = TWEEK
End If
If ((tableWages(n).startShift >= sHOUR And tableWages(n).startShift < eHOUR) _
Or (tableWages(n).endShift > sHOUR And tableWages(n).endShift < sHOUR) _
Or (eHOUR > tableWages(n).startShift And eHOUR < tableWages(n).endShift) _
Or (sHOUR >= tableWages(n).startShift And sHOUR < tableWages(n).endShift)) _
And tableWages(n).day = TDAY _
And tableWages(n).week = TWEEK Then
WAGESPERHOUR = WAGESPERHOUR + tableWages(n).wage
End If
Next
End Function
The tableWages(n).week is supposed to get "week 1" from the cell (n,2); but it just doesn't; I use inspection and the cell values is correct but when is time to assign the value it stays in (""); the worse part is that it worked before, I close the book open it again and stopped working.
I'm also attaching a printscreen, with the inspector showing that the cell does have "Week 1" but for some reason it can't save in the array. Every other variable works.
Thanks for the help
EDIT
Print Screen of the cells where it need to get the value.


Sheets(nSheet).Cells(inRow + n, weekCol)is evaluating to something likeWeek 1, then I would have to look at a workbook demonstrating the problem to figure out what is wrong. It's a simple assignment statement. If the data is correct, there must be something else interefering.