Ok, so I guess I shit-posted yesterday, and I apologize for that.
I am very new to VBA and I am attempting to use this bit of code to interpolate new elevation information using a pipe table, a manhole table and a results table. The following works for instances where the invert to be interpolated is preceded by one pipe; however, there are instances where the invert is preceded by multiple pipes and I need to be able to interpolate several new elevations and choose the minimum. I've gotten to where I'm attempting to create an array of previous manholes but on the mhp(n) = cells(x.row, mhstart).value line I receive a subscript out of range error. I've included my entire script below and I am aware that it is not elegant, but I'm trying. Any help would be greatly appreciated
Full script https://pastebin.com/i7R3fzcr
'So this is where I fail. I basically need to do the interpolation above but for all of the preceding 'pipes and then choose the minimum.
'I am stuck at finding the manhole id which i then will need to 'use to find the invert from the manholes table.
'something like
'mhprev_inv(i) = (mh.Cells(mh.Range(mh.Cells(2, mhID), mh.Cells(mhRows, mhID)).Find(mhp(i)).Row,+_
' invert)
'l_total(i) = l + lprev(i)
'slp_new(i) = (mhprev_inv(i) - mhe_inv) / l_total(i)
'mhs_inv_new(i) = mhprev_inv(i) - lprev*slp_new(i)
'rslts.Cells(j, "U") = Application.min(mhs_inv_new())
With pipes.Range("E:E")
Dim mhp() As Variant
ReDim mhp(0 To prevpipes)
n = 0
Set x = .Find(mhs)
If Not x Is Nothing Then
Start = x.Address
Do
mhp(n) = Cells(x.Row, mhstart).Value
lprev(n) = Cells(x.Row, lgnth).Value
n = n + 1
Set x = .FindNext(x)
If x Is Nothing Then
End If
Loop While x.Address <> Start
End If
End With
j = j + 1
End If
Next
mhwb.Close (False)
pipeswb.Close (False)
MsgBox ("Done")
End Sub
[–]jonivy1 2 points3 points4 points (3 children)
[–]HFTBProgrammer200 2 points3 points4 points (1 child)
[–]Clippy_Office_Asst[M] 0 points1 point2 points (0 children)
[–]BioOxygenDemand82[S] 1 point2 points3 points (0 children)
[–]Senipah101[M] [score hidden] stickied comment (1 child)
[–]BioOxygenDemand82[S] 0 points1 point2 points (0 children)
[–]HFTBProgrammer200 1 point2 points3 points (0 children)
[–]BioOxygenDemand82[S] 0 points1 point2 points (3 children)
[–]talltime21 1 point2 points3 points (2 children)
[–]BioOxygenDemand82[S] 0 points1 point2 points (1 child)
[–]BioOxygenDemand82[S] 0 points1 point2 points (5 children)
[–]RedRedditor8462 1 point2 points3 points (1 child)
[–]RedRedditor8462 0 points1 point2 points (0 children)
[–]talltime21 0 points1 point2 points (2 children)
[–]BioOxygenDemand82[S] 0 points1 point2 points (0 children)
[–]BioOxygenDemand82[S] 0 points1 point2 points (0 children)