I'm having trouble with my arrays in my code. When I try to pull things from excel forms, everything gets messed up, but when I initialize all the variables in my code, it seems to work. I'm starting to think my problem may be that Range uses two dimensional arrays, while I really only am using a 1D array. Any way to pull the data from excel without it being in a 2D array?
Here's what I had initially (with variables defined in the code)
If NumPatientOne > 0 Then
For k = 1 To 4
For j = 1 To 3
For i = 1 To 2
If CritStagingAvail(i) <= CurrentTime Then
If HospitalNICUBeds(j) >= 1 Then
If CCTavail(k) <= CurrentTime Then
NumPatientOne = NumPatientOne - 1
CritStagingAvail(i) = CurrentTime + CritStagingTime
HospitalNICUBeds(j) = HospitalNICUBeds(j) - 1
CCTavail(k) = 2 * Distance(j) + CurrentTime + 2 * CCTLoad
End If
End If
End If
Next i
Next j
Next k
End If
When I used arrays that pulled from excel, the line that utilized my distance variable stopped working correctly. Here is what I have now:
For Each j In HospitalNICUBeds
For Each k In CCTavail
For Each m In Distance
For i = 1 To 2
If NumPatientOne > 0 Then
If CritStagingAvail(i) <= CurrentTime Then
If j >= 1 Then
If k <= CurrentTime Then
NumPatientOne = NumPatientOne - 1
CritStagingAvail(i) = CurrentTime + CritStagingTime
j = j - 1
k = 2 * m + CurrentTime + 2 * CCTLoad
End If
End If
End If
End If
Next i
Next
Next
Next
The thing is, I want to iterate Distance by HospitalNICUBeds, but I can't figure out how to do it when using the For Each function. Thanks for your help!
Bookmarks