LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Solver

I have a peice of code which adds data to a spreadshet via a form and then
runs a solver command, however, the solver code only runs for row 4 at the
moment. How can i make it so that the row in which data has just been copied
is the one in which the solver runs?
Thanks for any help.

'Add Button
Private Sub Add_Click()
'Data Validation
ActiveWorkbook.Sheets("Bookings").Activate
ActiveSheet.Unprotect
Range("b4").Select
Do
'First Empty Cell
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
'Copy Data
ActiveCell.Value = tourref.Value
ActiveCell.Offset(0, -1) = DateText.Value
ActiveCell.Offset(0, 1) = CountryText.Value
ActiveCell.Offset(0, 2) = PlaceText.Value
ActiveCell.Offset(0, 3) = AdultsText.Value
ActiveCell.Offset(0, 4) = ChildrenText.Value
ActiveCell.Offset(0, 5) = CoachesText.Value
ActiveCell.Offset(0, 6) = MinibusesText.Value
ActiveCell.Offset(0, 7) = TourbusesText.Value
'Solver
SolverOk SetCell:="$K$4", MaxMinVal:=2, ValueOf:="0",
ByChange:="$H$4:$J$4"
SolverAdd CellRef:="$H$4", Relation:=4, FormulaText:="integer"
SolverAdd CellRef:="$I$4", Relation:=4, FormulaText:="integer"
SolverAdd CellRef:="$J$4", Relation:=4, FormulaText:="integer"
SolverAdd CellRef:="$H$4", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$I$4", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$J$4", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$L$4", Relation:=3, FormulaText:="$F$4+$G$4"""
SolverSolve
Range("b4").Select
End Sub

--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Solver help. Soccer boy[_2_] Excel Discussion (Misc queries) 0 March 11th 09 03:18 PM
Will Solver do the job? Mark Excel Discussion (Misc queries) 7 March 11th 09 01:33 AM
Solver Richard4926 Excel Discussion (Misc queries) 4 December 17th 07 08:28 PM
XL Solver Baldy_Couso Excel Worksheet Functions 1 February 5th 07 02:00 PM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM


All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"