Excel macro for Solver

L

Legacy 436997

Guest
Hi


This is my first post. I’m trying to set up a macro that uses Solver and I have some code below. I was wondering if someone could take a look to see if I’m on the right track.


This is what the macro should be doing:


Numbers will always be present in one or all of the following cells: G18, K18 and O18. When the macro starts it does a calculation on each cell with a number in it and then posts the answer in the cell below it. So as an example, for cell K18 3.00 would produce the answer 0.75 and would be posted in cell K19.


Any input/comments would be appreciated.



Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("MyInputs")) Is Nothing Then Exit Sub
If Target = 0 Or Target = vbNullString Then Exit Sub
Dim cLet As String
Target.Offset(1, 0).ClearContents
If Target.Value > 0 Then
cLet = Target.Offset(2, 0).Value
Range("I14").Formula = "=I14+INDIRECT(""" & cLet & """&""14"")"
Range("J14").Formula = "=J14/2*INDIRECT(""B""&INDIRECT(""" & cLet & """&""14""))"
' Run Solver
Application.Run ("RunSolver")
'Reset
'Activecell = 0
End If
End Sub
Code:

<style type="text/css">p { margin-bottom: 0.25cm; direction: ltr; color: rgb(0, 0, 10); line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; }a:link { }</style>


<style type="text/css">p { margin-bottom: 0.25cm; direction: ltr; color: rgb(0, 0, 10); line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; }a:link { }</style>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Have a look here.
Apparently it's solved.
You could ask if they would kindly post or link to the solution.
 
Upvote 0
I did some research and found that code. I thought I could use it as a starting point for my macro, if it works. that macro will not work for my use.

Thanks
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,188
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top