Hi everyone,
I have been looking at this code for way too long and cannot figure out the issue, so any insight would be appreciated!
I am trying to create a goal seek in VBA that will look at the baseline production of people at a given year and change a value to hit a target production of people in that same year.
The code works perfectly until we get to the goalseek piece in the Macro and TargetFound keeps coming up as false.
I have pasted the code below and added a photo of the sheet that the macro should be working on:
For Each cell In ActiveSheet.Range("C13:" & Cells(13, Cells(13, Columns.Count).End(xlToLeft).Column).Address)
If Trim(cell.Value) <> "" Then
cadreName = Left(Trim(cell.Value), InStrRev(cell.Value, " ") - 1)
cadreColRef = Split(cell.Address, "$")(1)
If (Trim(ActiveSheet.Range(cadreColRef + "21")) <> "") Then
targetMethod = LCase(Trim(ActiveSheet.Range(cadreColRef + "21")))
Select Case targetMethod
Case "manual entry"
targetValRow = "25"
Case Else
targetValRow = "23"
End Select
If (Trim(ActiveSheet.Range(cadreColRef + targetValRow)) <> "" And IsNumeric(Trim(ActiveSheet.Range(cadreColRef + targetValRow)))) Then
originalScaleUp = ActiveSheet.Range(cadreColRef + "41").Value
TargetFound = Sheets("Assumptions Tab").Range(cadreColRef + "27").GoalSeek(Goal:=Sheets("Assumptions Tab").Range(cadreColRef + targetValRow).Value, ChangingCell:=Sheets("Assumptions Tab").Range(cadreColRef + "41"))
I have been looking at this code for way too long and cannot figure out the issue, so any insight would be appreciated!
I am trying to create a goal seek in VBA that will look at the baseline production of people at a given year and change a value to hit a target production of people in that same year.
The code works perfectly until we get to the goalseek piece in the Macro and TargetFound keeps coming up as false.
I have pasted the code below and added a photo of the sheet that the macro should be working on:
For Each cell In ActiveSheet.Range("C13:" & Cells(13, Cells(13, Columns.Count).End(xlToLeft).Column).Address)
If Trim(cell.Value) <> "" Then
cadreName = Left(Trim(cell.Value), InStrRev(cell.Value, " ") - 1)
cadreColRef = Split(cell.Address, "$")(1)
If (Trim(ActiveSheet.Range(cadreColRef + "21")) <> "") Then
targetMethod = LCase(Trim(ActiveSheet.Range(cadreColRef + "21")))
Select Case targetMethod
Case "manual entry"
targetValRow = "25"
Case Else
targetValRow = "23"
End Select
If (Trim(ActiveSheet.Range(cadreColRef + targetValRow)) <> "" And IsNumeric(Trim(ActiveSheet.Range(cadreColRef + targetValRow)))) Then
originalScaleUp = ActiveSheet.Range(cadreColRef + "41").Value
TargetFound = Sheets("Assumptions Tab").Range(cadreColRef + "27").GoalSeek(Goal:=Sheets("Assumptions Tab").Range(cadreColRef + targetValRow).Value, ChangingCell:=Sheets("Assumptions Tab").Range(cadreColRef + "41"))