CedricMattelaer
New Member
- Joined
- Jun 16, 2011
- Messages
- 37
Hello all,
I downloaded a VBA excel add-in here made by Samuel E. Buttrey, calling the freeware lp_solve program (information can be found here).
When I start the add-in I have to select two ranges at some point in the beginning. The add-in then calculates everything I need. It works fine most of the time but as I have to apply this add-in a vast amount of time I wondered whether I could automatize that, ie instead of selecting it manually, change the macro a bit so that the ranges I normally enter by hand are provided by the macro.
Concretely, I think that the code processing the variable range I enter in the first box is
and the second one is
The actual add-in starts with:
I already tried to put something like what is shown underneath in the beginning of the matrix:
But then for example the evaluation of the statement
results in an type mismatch.
Any of you excel masterminds got any ideas or suggestions?
Thank you in advance!
I downloaded a VBA excel add-in here made by Samuel E. Buttrey, calling the freeware lp_solve program (information can be found here).
When I start the add-in I have to select two ranges at some point in the beginning. The add-in then calculates everything I need. It works fine most of the time but as I have to apply this add-in a vast amount of time I wondered whether I could automatize that, ie instead of selecting it manually, change the macro a bit so that the ranges I normally enter by hand are provided by the macro.
Concretely, I think that the code processing the variable range I enter in the first box is
Code:
Private Sub VarRef_BeforeDragOver(Cancel As Boolean, ByVal Data As MSForms.DataObject, ByVal x As stdole.OLE_XPOS_CONTAINER, ByVal y As stdole.OLE_YPOS_CONTAINER, ByVal DragState As MSForms.fmDragState, Effect As MSForms.fmDropEffect, ByVal Shift As Integer)
End Sub
Code:
Private Sub CostRef_BeforeDragOver(Cancel As Boolean, ByVal Data As MSForms.DataObject, ByVal x As stdole.OLE_XPOS_CONTAINER, ByVal y As stdole.OLE_YPOS_CONTAINER, ByVal DragState As MSForms.fmDragState, Effect As MSForms.fmDropEffect, ByVal Shift As Integer)
End Sub
The actual add-in starts with:
Code:
Private Sub TransportRun_Click()
Dim objOut() As Double, objVal As Double, constVec() As Double, solution() As Double
Dim solutionOut() As Double
Dim direction As Long, xCount As Long, constCount As Long, _
intCount As Long, intVec() As Long, status As Long
'
' In the transportation problem, it's always a minimum. For now.
'
direction = 0
'
' Elementary error checking: Check that the solution exists and has the right length
'
If VarRef.Value = "" Then
MsgBox "No variable range entered; try again"
Exit Sub
End If
'
' Check size
'
soln = Range(VarRef.Value)
'
' Find out number of variables and number of constraints. The CostRef should be
' two columns wider and two rows longer than the VarRef
'
If CostRef.Value = "" Then
MsgBox "Nothing entered for objective function coefficients -- and that's bad"
Exit Sub
End If
objIn = Range(CostRef.Value)
yCount = UBound(objIn, 1) ' counts rows
xCount = UBound(objIn, 2) ' counts columns
etc.
I already tried to put something like what is shown underneath in the beginning of the matrix:
Code:
Dim Varref as Range
Set Varref = Range(Cells(624, 38), Cells(653, 53))
Code:
If Varref.Value = "" Then
Any of you excel masterminds got any ideas or suggestions?
Thank you in advance!