Stop Macro if Data is .........

christian21077

New Member
Joined
Mar 30, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello everyone. I need to be able to stop a macro if the data of certain cells go to a negative number. The cells in question have a formula. (I dont know if that matters or no). Let me give you some background. The macro I have is basically using "goal seek" to find out angles. The macro is for several cells. Two Things I need to do. 1- I need to tell the macro to stop looking if cells BI31 through BK31 are negative numbers. 2- I need to know where to place the line, at the end of whole macro, or in between each process. Take a look at the macro I have:

Sub FindAngle()
'
' FindAngle Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("BP31").GoalSeek Goal:=0, ChangingCell:=Range("BL31")
Range("BP32").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("BP32").GoalSeek Goal:=0, ChangingCell:=Range("BL32")
Range("BP33").Select

This macro goes up to BL44. So pretty much the same thing throughout the macro just different ranges. Your help will be appreciated.
 

Attachments

  • Macro Sheet.jpg
    Macro Sheet.jpg
    128.2 KB · Views: 7

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Watch MrExcel Video

Forum statistics

Threads
1,129,791
Messages
5,638,337
Members
417,021
Latest member
moon miner

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
Top