Adding GoalSeek into VBA with If Statement

jason8490

New Member
Joined
Aug 21, 2012
Messages
30
I'm a total VBA noob but for the workbook I'm making VBA seemed like the only thing that to get rid of the manual processes. I can't seem to find exactly how I would create or add something like this into my code.

What I am doing: Running XIRR on hundred plus items. I built a sheet that runs XIRR on just one item. I have a macro (see below) that loops through a list of Identifiers on one sheet and plugs them into my XIRR sheet (Don't want to run XIRR on all items at once because of calc speed). After it plugs in the Identifier and calculates it grabs the information and pastes it back into my Identifier list.

What I want to do: I want to add into my macro if possible or if easier create another macro to run a goal seek function. The thing is I only want it run if the XIRR returns at 10% or more. Then return that information and paste it back into my Identifier Dump.

Goal Seeks are finicky as is, so sometimes I have to adjust the "changing cell" to get exactly 10% back.


Code:
Range("F5").GoalSeek Goal:=0.1, ChangingCell:=Range("H5")








Code:
Sub XIRR3()'
' XIRR3 Macro
'


'
      ' Select cell A2, *first line of data*.
    Do Until IsEmpty(ActiveCell)
         Selection.Copy
         Sheets("Sheet1").Select
         Range("D5").Select
         ActiveSheet.Paste
         Application.CutCopyMode = False
         Calculate
         Range("E5:J5").Select
         Selection.Copy
         Sheets("LLID Dump").Select
         ActiveCell.Offset(0, 1).Range("A1").Select
         Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
             xlNone, SkipBlanks:=False, Transpose:=False
         ActiveCell.Offset(1, -1).Range("A1").Select
   Loop
End Sub
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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