Hi Everyone, I know there are a few threads for this already, but I have a specific question that doesn't seem to be covered, rather than dragging up old threads that could get messy, I thought I would start a new one.
I found some script on this forum similar to the one below (just tweeked the locations a bit to make it fit my sheet).
The sheet I use it on, is a pricing tool, that lets people calculate a sale price based on a % Gross margin, however this could be anywhere from 30 lines, to 3000 lines. As it is fairly complex, the goal seek can take a while when doing more than 300 or so lines, so i would like to give the user the option of specifying a start and end row for the goal seek. (it always uses the same column, it's just the rows that will vary) so for example, they could specify the option of performing the goal seek on rows 220 through 880 if they wanted, without having to go in and change the script (as I am doing currently when anyone needs to use it)
Anyone able to help??
Sub MultipleGoalSeekA()
Dim aPercentage As Variant, aCell As Range
aPercentage = Application.InputBox("Enter target percentage:" & vbCr & _
"(for 10% enter 10, for 0.5% enter 0.5)", Type:=1)
If aPercentage = False Then Exit Sub
aPercentage = aPercentage / 100
On Error Resume Next 'This prevents an error at blank cells
For Each aCell In Range("U3:U303")
aCell.GoalSeek Goal:=aPercentage, ChangingCell:=aCell.Offset(0, -11)
Next aCell
End Sub
I found some script on this forum similar to the one below (just tweeked the locations a bit to make it fit my sheet).
The sheet I use it on, is a pricing tool, that lets people calculate a sale price based on a % Gross margin, however this could be anywhere from 30 lines, to 3000 lines. As it is fairly complex, the goal seek can take a while when doing more than 300 or so lines, so i would like to give the user the option of specifying a start and end row for the goal seek. (it always uses the same column, it's just the rows that will vary) so for example, they could specify the option of performing the goal seek on rows 220 through 880 if they wanted, without having to go in and change the script (as I am doing currently when anyone needs to use it)
Anyone able to help??
Sub MultipleGoalSeekA()
Dim aPercentage As Variant, aCell As Range
aPercentage = Application.InputBox("Enter target percentage:" & vbCr & _
"(for 10% enter 10, for 0.5% enter 0.5)", Type:=1)
If aPercentage = False Then Exit Sub
aPercentage = aPercentage / 100
On Error Resume Next 'This prevents an error at blank cells
For Each aCell In Range("U3:U303")
aCell.GoalSeek Goal:=aPercentage, ChangingCell:=aCell.Offset(0, -11)
Next aCell
End Sub