I'm having a problem with using a loop to assign cell values to an array variable. The values are only running for the first i and the msg box is only saying the first two instead of the four that it should find. Any help would be greatly appreciated.
Type Plants
Name As String
Capacity As Integer
End Type
Type Warehouses
Name As String
Demand As Integer
End Type
Sub plantInfo()
Dim Plant() As Plants
Dim nPlants As Integer
Dim i As Integer
Dim msg As String
With Range("A3")
nPlants = Range(.Offset(1, 0), .End(xlDown).Offset(-1, 0)).Rows.Count
ReDim Plant(1 To nPlants)
For i = 1 To nPlants
Plant(i).Name = .Offset(i, 0).Value
Plant(i).Capacity = .Offset(i, 6).Value
msg = msg & "production from " & Plant(i).Name & " cannot exceed its capacity of " & Plant(1).Capacity & "." & vbLf
Next i
End With
MsgBox msg
End Sub
Type Plants
Name As String
Capacity As Integer
End Type
Type Warehouses
Name As String
Demand As Integer
End Type
Sub plantInfo()
Dim Plant() As Plants
Dim nPlants As Integer
Dim i As Integer
Dim msg As String
With Range("A3")
nPlants = Range(.Offset(1, 0), .End(xlDown).Offset(-1, 0)).Rows.Count
ReDim Plant(1 To nPlants)
For i = 1 To nPlants
Plant(i).Name = .Offset(i, 0).Value
Plant(i).Capacity = .Offset(i, 6).Value
msg = msg & "production from " & Plant(i).Name & " cannot exceed its capacity of " & Plant(1).Capacity & "." & vbLf
Next i
End With
MsgBox msg
End Sub